Log in

View Full Version : Solved: noob sent email question



chungtinhlak
02-24-2009, 07:01 AM
Hi, this is my first time writing a macro in outlook, can someone tell me what is wrong with this.



Option Explicit
Sub dailyexitandarrival()
Dim objmail As Outlook.MailItem
Dim myattachements As Collection

Set objmail = Outlook.CreateItem(olMailItem)
With objmail
.BodyFormat = olFormatPlain
.Body = "Good Morning All, attached is Daily Exits and Arrivals. Please Click cancel when asked to updated."
.Display
.To = "John@smith.com"
End With
Set myattachements = objmail.Attachments
myattachements.Add "C:\\daily-arrivals-exits.ppt"
objmail.Send

End Sub

JKwan
02-24-2009, 07:41 AM
Try this

Sub dailyexitandarrival()
Dim objmail As Outlook.MailItem
Dim myattachements As Collection

Set objmail = Outlook.CreateItem(olMailItem)
With objmail
.BodyFormat = olFormatPlain
.Body = "Good Morning All, attached is Daily Exits and Arrivals. Please Click cancel when asked to updated."
.Display
.To = "John@smith.com"
.Attachments.Add "C:\daily-arrivals-exits.ppt"
End With
End Sub

chungtinhlak
02-24-2009, 07:11 PM
thanks, works great