Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Howto place data in the message text from outlook

Status
Not open for further replies.

sciencer

Technical User
Jan 7, 2004
17
NL
Hi

I'am wondering if I can place tekst in the Message tekst from an e-mail by using VBA

Greetings Raymond

 
The following procedure will send an Email from Excel:
Code:
Sub Send_Email()
' Be Sure to set a reference to MS Outlook before using this procedure.
' Go to Tools->References and select the Outlook library from the list and press OK.

Dim MailSubject As String, MailBody As String
Dim newOL As New Outlook.Application, newMail As MailItem

Set newOL = New Outlook.Application
Set newMail = newOL.CreateItem(olMailItem)
MailSubject = "Enter your Subject here."
MailBody = "Enter your Email text here."

With newMail
    .To = "noone@nowhere.com"
    .Subject = MailSubject
    .Body = MailBody ' This is your message text
        
    ' You can either Display the Email for editing or
    ' Send it directly.
    
    .Display ' This will display the Email for editing
    ' .Send ' This will send the Email directly

End With

' newOL.Quit 'Closes Outlook

Set newMail = Nothing
Set newOL = Nothing

End Sub
Please notice the .Body = MailBody line.

Peace!! [peace]

Mike

Didn't get the answers that you wanted? Take a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top