Automatically send messages from Outbox

G

Guest

TIA:

Trying to send email after adding attachments in Outbox...the following code
producess error "item has been moved or deleted".

If I just Save the emails, all is OK but they will not be sent when I click
" Send and Receive" after attaching files through code.

What do I need to do in code to have the emails Sent in Outbox so that when
I click " Send and Receive" they will go...

Thanks,
Joel

Sub AddAttachmentToSelectedMessages()
Dim oFolder As Outlook.MAPIFolder
Dim items As Outlook.items
Dim objItem As MailItem


Set items =
Application.GetNamespace("MAPI").GetDefaultFolder(olFolderOutbox).items

For Each objItem In items

If objItem.To = "'(e-mail address removed)'" Then
objItem.Attachments.Add ("C:\115.xls")
objItem.Send
End If

If objItem.To = "'(e-mail address removed)'" Then
objItem.Attachments.Add ("C:\116.xls")
objItem.Send
End If

If objItem.To = "'(e-mail address removed)'" Then
objItem.Attachments.Add ("C:\117.xls")
objItem.Send
End If

Next
End Sub

Thanks again, Joel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top