jerry12302
Active Member
- Joined
- Apr 18, 2005
- Messages
- 456
- Office Version
- 2010
- Platform
- Windows
Every month I have to send emails to various clients with files attached, a different file for each client. I wanted to automate the task. I found some vba code on the web to use, requiring the use of outlook. I configured outlook to receive and send emails using my AOL account. It was working fine, able to send and receive manually from outlook. I then tried the code, and at first, it worked fine.
Now it is not working, and worse, I can't even send emails manually through outlook anymore.
Sub MailerTest()
Dim objol As New Outlook.Application
Dim objmail As MailItem
Set objol = New Outlook.Application
Set objmail = objol.createitem(olmailitem)
With objmail
.To = "someemailaddress@yahoo.com"
.cc = "ccsomeemailaddress@hotmail.com"
.Subject = "Test 12/9 10:39"
.Body = "This is a Test 12/9 10:39"
.NoAging = True
.Attachments.Add "C:\somefile.xls"
.display
End With
Set objmail = Nothing
Set objol = Nothing
SendKeys "%{s}", True
End Sub
The code above was the original attempt, which worked, then I added a loop to go through the list of email addresses and appropriate file attachments. It worked at first, then I started getting errors in Outlook, now it won't work, and even this original code doesn't work.
Here are the errors I get in Outlook:
Your message did not reach some or all of the intended recipients.
Subject: Test 12/9 10:39
Sent: 12/9/2005 10:41 AM
The following recipient(s) could not be reached:
'someemailaddress@yahoo.com' on 12/9/2005 10:41 AM
554 TRANSACTION FAILED
'ccsomeemailaddress@hotmail.com' on 12/9/2005 10:41 AM
554 TRANSACTION FAILED
(of course, the actual email addresses have been changed for illustrative purposes here)
Any suggestions would be greatly appreciated.