laurenbattaglia
Technical User
I am trying to write vb to send several different mail messages with attachments. The issue I am running into, is if one of the recipients is taken out of the address book, then the code bombs when it hits that name. Is there a way to error check the names before sending out proceeding to creating and sending the emails? The following is what I have so far, but this is my first time writing VB for outlook. Thanks for the help.
Sub SendMyMail
Set myItemss = Outlook.CreateItem(olMailItem)
myItemss.To = "Jones, Dan"
myItemss.Subject = "Sales and Services PTO"
Set myAttachments = myItemss.Attachments
myAttachments.Add "\\PTO Reports\PTO Process\Sales and Services PTO.xls", _
olByValue, 1, "Sales and Services PTO"
Set myIteme = Outlook.CreateItem(olMailItem)
myIteme.To = "Battaglia, Lauren"
myIteme.Subject = "Operations and Engineering PTO"
Set myAttachments = myIteme.Attachments
myAttachments.Add "\\PTO Reports\PTO Process\Operations and Engineering PTO.xls", _
olByValue, 1, "Operations and Engineering PTO"
myItemss.Send
myIteme.Send
End Sub
Sub SendMyMail
Set myItemss = Outlook.CreateItem(olMailItem)
myItemss.To = "Jones, Dan"
myItemss.Subject = "Sales and Services PTO"
Set myAttachments = myItemss.Attachments
myAttachments.Add "\\PTO Reports\PTO Process\Sales and Services PTO.xls", _
olByValue, 1, "Sales and Services PTO"
Set myIteme = Outlook.CreateItem(olMailItem)
myIteme.To = "Battaglia, Lauren"
myIteme.Subject = "Operations and Engineering PTO"
Set myAttachments = myIteme.Attachments
myAttachments.Add "\\PTO Reports\PTO Process\Operations and Engineering PTO.xls", _
olByValue, 1, "Operations and Engineering PTO"
myItemss.Send
myIteme.Send
End Sub