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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using outlook via Visual Basic

Status
Not open for further replies.

Agent009

Programmer
Apr 4, 2003
96
IE
I want to be able to open up outlook with an attached file. So far my code does all of this successfully:

Dim objOutlook As New Outlook.Application
Dim objOutlookmsg As Outlook.MailItem

Set objOutlookmsg = objOutlook.CreateItem(olMailItem)
objOutlookmsg.Attachments.Add sPath
objOutlookmsg.Subject = "Hello there"
objOutlookmsg.Display
Set objOutlook = Nothing

However along with the attachment, and the subject matter, i want to also include a standard message just above the attachment.

I reckon its only one line of code, but How is this done?

Thanks in advance,

Agent009
 
Try:

objOutlookmsg.MsgNoteText = "hi"


________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
You could also try

objOutlookmsg.body = "Hello there"

 
Thanks,

Agent009.

"Do you expect me to talk?, NO MR.BOND, I EXPECT YOU TO DIE!!"
 
In case the user has the default e-mail format set to RTF, add a couple of blank lines to the body then add the attachment:

Set objOutlookmsg = objOutlook.CreateItem(olMailItem)
objOutlookmsg.Body = "My message" & vbCrLf & vbCrLf
objOutlookmsg.Attachments.Add sPath

Otherwise you may end up with the attachment within the message text.

Paul Bent
Northwind IT Systems
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top