Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Sending An Email In Excel Programmatically W/O Sending An Object

Hi,

I want to send an email in excel programmatically but I don't want to
send a workbook or worksheet. I also need to be able to specify the
subject, recipients, and message.

I'm looking for something similar to the 'docmd.sendobject' method in
an access database. Is there anything like that?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 245
Default Sending An Email In Excel Programmatically W/O Sending An Object

Search excels Help file for Routing slip.

" wrote:

Hi,

I want to send an email in excel programmatically but I don't want to
send a workbook or worksheet. I also need to be able to specify the
subject, recipients, and message.

I'm looking for something similar to the 'docmd.sendobject' method in
an access database. Is there anything like that?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Sending An Email In Excel Programmatically W/O Sending An Object

On Dec 1, 8:12 am, Office_Novice
wrote:
Search excels Help file for Routing slip.

" wrote:
Hi,


I want to send an email in excel programmatically but I don't want to
send a workbook or worksheet. I also need to be able to specify the
subject, recipients, and message.


I'm looking for something similar to the 'docmd.sendobject' method in
an access database. Is there anything like that?


yeah I found routing slip. It sends the workbook. That isn't what I
want to do. I do not want to send an object to the recipient - just a
message, and I don't want the recipient to route it to anyone else. I
am going to send out passwords for a database application. I figured
it would be easier to reference and move from cell to cell including
the cell values in the message text because I don't know how to access
and move from record to record in a database table.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Sending An Email In Excel Programmatically W/O Sending An Object

Start with this example
http://www.rondebruin.nl/mail/folder3/smallmessage.htm

Read also the tips page (link is on the page)

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


wrote in message ...
On Dec 1, 8:12 am, Office_Novice
wrote:
Search excels Help file for Routing slip.

" wrote:
Hi,


I want to send an email in excel programmatically but I don't want to
send a workbook or worksheet. I also need to be able to specify the
subject, recipients, and message.


I'm looking for something similar to the 'docmd.sendobject' method in
an access database. Is there anything like that?


yeah I found routing slip. It sends the workbook. That isn't what I
want to do. I do not want to send an object to the recipient - just a
message, and I don't want the recipient to route it to anyone else. I
am going to send out passwords for a database application. I figured
it would be easier to reference and move from cell to cell including
the cell values in the message text because I don't know how to access
and move from record to record in a database table.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 245
Default Sending An Email In Excel Programmatically W/O Sending An Obje

I Modified Rons Code a bit to be Table driven. Add Recipents in Column "A"
Subject in Column "B" And Body in Column "C". It will loop through Column
"A" And send to each Recipent.

Sub MailItem()
Dim Outlook As Object
Dim Mail As Object
Dim Body As String
Dim i As Long
Dim LastRow As Long
Dim ws As Worksheet

Set ws = ActiveWorkbook.Worksheets(1)
LastRow = ws.Cells(Rows.Count, 1).End(xlUp).Row

For i = 2 To LastRow
Set Outlook = CreateObject("Outlook.Application")
Outlook.Session.Logon
Set Mail = Outlook.CreateItem(0)

Body = ws.Range("C" & i).Value

On Error Resume Next

With Mail
.To = ws.Range("A" & i).Value
.Subject = ws.Range("B" & i).Value
.Body = Body
.send
End With
Next
On Error GoTo Morgue

ErrorOut:
Set Outlook = Nothing
Set Mail = Nothing
Exit Sub
Morgue:
MsgBox Err.Description, vbCritical
Resume ErrorOut
End Sub

Good Luck!

"Ron de Bruin" wrote:

Start with this example
http://www.rondebruin.nl/mail/folder3/smallmessage.htm

Read also the tips page (link is on the page)

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


wrote in message ...
On Dec 1, 8:12 am, Office_Novice
wrote:
Search excels Help file for Routing slip.

" wrote:
Hi,

I want to send an email in excel programmatically but I don't want to
send a workbook or worksheet. I also need to be able to specify the
subject, recipients, and message.

I'm looking for something similar to the 'docmd.sendobject' method in
an access database. Is there anything like that?


yeah I found routing slip. It sends the workbook. That isn't what I
want to do. I do not want to send an object to the recipient - just a
message, and I don't want the recipient to route it to anyone else. I
am going to send out passwords for a database application. I figured
it would be easier to reference and move from cell to cell including
the cell values in the message text because I don't know how to access
and move from record to record in a database table.




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Sending An Email In Excel Programmatically W/O Sending An Object

On Dec 1, 8:32 am, "Ron de Bruin" wrote:
Start with this examplehttp://www.rondebruin.nl/mail/folder3/smallmessage.htm

Read also the tips page (link is on the page)

--

Regards Ron de Bruinhttp://www.rondebruin.nl/tips.htm

wrote in ...
On Dec 1, 8:12 am, Office_Novice
wrote:
Search excels Help file for Routing slip.


" wrote:
Hi,


I want to send an email in excel programmatically but I don't want to
send a workbook or worksheet. I also need to be able to specify the
subject, recipients, and message.


I'm looking for something similar to the 'docmd.sendobject' method in
an access database. Is there anything like that?


yeah I found routing slip. It sends the workbook. That isn't what I
want to do. I do not want to send an object to the recipient - just a
message, and I don't want the recipient to route it to anyone else. I
am going to send out passwords for a database application. I figured
it would be easier to reference and move from cell to cell including
the cell values in the message text because I don't know how to access
and move from record to record in a database table.


Thank you for the help Ron. I am using the following and it is only
sending one email - everything in the email looks great - but I need
it to loop through every cell and send a new email for every cell.
What do you think I should do differently?

Sub SendPasswords()

Dim OutApp As Object
Dim OutMail As Object
Dim strBody As String
Dim MyRecipient As String
Dim MyMessage As String
Dim MySubject As String
Dim I As Integer


Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
Range("B2").Select
I = ActiveCell.Row

On Error Resume Next
Do Until I = 7
MyRecipient = "Robin Tanner"
MySubject = "Ticketing System and Password Release"
MyMessage = "Your username is: " & ActiveCell.Text & vbCrLf &
vbCrLf & ActiveCell.Offset(0, 2).Text
With OutMail
.To = MyRecipient
.CC = ""
.BCC = ""
.Subject = MySubject
.Body = MyMessage
.Send
End With
DoEvents
ActiveCell.Offset(1, 0).Select
I = ActiveCell.Row
Debug.Print I
Loop



End Sub
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Sending An Email In Excel Programmatically W/O Sending An Object

There are a lot of examples on my site
http://www.rondebruin.nl/sendmail.htm

Check it out


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


wrote in message ...
On Dec 1, 8:32 am, "Ron de Bruin" wrote:
Start with this examplehttp://www.rondebruin.nl/mail/folder3/smallmessage.htm

Read also the tips page (link is on the page)

--

Regards Ron de Bruinhttp://www.rondebruin.nl/tips.htm

wrote in ...
On Dec 1, 8:12 am, Office_Novice
wrote:
Search excels Help file for Routing slip.


" wrote:
Hi,


I want to send an email in excel programmatically but I don't want to
send a workbook or worksheet. I also need to be able to specify the
subject, recipients, and message.


I'm looking for something similar to the 'docmd.sendobject' method in
an access database. Is there anything like that?


yeah I found routing slip. It sends the workbook. That isn't what I
want to do. I do not want to send an object to the recipient - just a
message, and I don't want the recipient to route it to anyone else. I
am going to send out passwords for a database application. I figured
it would be easier to reference and move from cell to cell including
the cell values in the message text because I don't know how to access
and move from record to record in a database table.


Thank you for the help Ron. I am using the following and it is only
sending one email - everything in the email looks great - but I need
it to loop through every cell and send a new email for every cell.
What do you think I should do differently?

Sub SendPasswords()

Dim OutApp As Object
Dim OutMail As Object
Dim strBody As String
Dim MyRecipient As String
Dim MyMessage As String
Dim MySubject As String
Dim I As Integer


Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
Range("B2").Select
I = ActiveCell.Row

On Error Resume Next
Do Until I = 7
MyRecipient = "Robin Tanner"
MySubject = "Ticketing System and Password Release"
MyMessage = "Your username is: " & ActiveCell.Text & vbCrLf &
vbCrLf & ActiveCell.Offset(0, 2).Text
With OutMail
.To = MyRecipient
.CC = ""
.BCC = ""
.Subject = MySubject
.Body = MyMessage
.Send
End With
DoEvents
ActiveCell.Offset(1, 0).Select
I = ActiveCell.Row
Debug.Print I
Loop



End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel VBA - Sending email [email protected] Excel Programming 0 April 24th 07 03:21 PM
Sending Email From Excel Help! lehainam[_19_] Excel Programming 3 September 6th 05 05:11 AM
sending email from Excel nuExcel[_4_] Excel Programming 1 June 7th 04 04:24 AM
Sending email from Excel Denise Posey Excel Programming 9 February 4th 04 09:29 AM
sending email in Excel Peter W[_2_] Excel Programming 1 September 15th 03 04:13 PM


All times are GMT +1. The time now is 07:22 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"