Seems that I’ve had some inconsistent results with using commas vs. semicolons as delimiters with recipients. Outlook seems to have let commas go on some occasions but then busts me on others. I find weird errors going away if I use the ;
From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of John Viescas
Sent: Friday, April 11, 2014 12:07 AM
To: MS_Access_Professionals@yahoogroups.com
Subject: Re: [MS_AccessPros] VBA to send email, error on certian addresses?
Michael-
Interesting. I would have thought it would die at the .Recipients.Add if it didn’t like the address. Would be interesting to Debug.Print the recipients in your error trap to see what it’s not liking. Are these just plain old email addresses? No funny punctuation or < > or ; characters?
John Viescas, Author
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications
SQL Queries for Mere Mortals
(Paris, France)
On Apr 10, 2014, at 11:33 PM, <Michael.P.Devlin@Hofstra.edu> <Michael.P.Devlin@Hofstra.edu> wrote:
I have been using the same code to send emails from MS Access (using automation) through Outlook. A few weeks ago, I ran into an issue with one database that would encounter an error on a particular email address. I recreated the message that was to be sent to that user, copied the email address into the TO line in a new Outlook message and the email was sent. I removed the email address from my source table, re-ran the job and a few addresses later, another bad email address. Repeated the previous "cure" and moved on. I encountered about 5 addresses that the automation found displeasing, but Outlook did not.
I moved on with my life, until a different database, used by a different user, using a different set of email addresses started encountering the same issue.
The error message is the generic: Error -2147024809: Could not complete the operation. One or more parameter values are not valid.
The error is thrown at the .send line.
For now, I am just catching the error, writing the offensive record to an audit table and resuming the code.
Any ideas?
Win 7, Office 2010, 64 bit
Incomplete code follows, but you get the idea...
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
.Subject = strSubjectline
.Body = strMessageBody
Set objOutlookRecip = .Recipients.Add(strEmailAddress)
objOutlookRecip.Type = olTo
'To preview the e-mail instead of automaticially sending it...
'Uncomment the "Display" line
'And comment the "Send" line
'.Display
.Send
End With
This email (and all attachments) is for the sole use of the intended recipient(s) and may contain privileged and/or proprietary information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.
| Reply via web post | Reply to sender | Reply to group | Start a New Topic | Messages in this topic (5) |
Tidak ada komentar:
Posting Komentar