Wednesday, September 29, 2004

Disable prompts when sending (Outlook) email via Access

If you have ever tried to automate the process of sending an email from within Access using VBA code, you may have seen this error message:

"A program is trying to automatically send e-mail on
your behalf. Do you want to Allow this?"

It makes you wait & then you HAVE to hit the Yes button for it to send the Email.

A SOLUTION that should work ...

Dim objOutlook As New Outlook.Application
Dim objMail As MailItem

Set objOutlook = New Outlook.Application
Set objMail = objOutlook.CreateItem(olMailItem)

EmailAddr = "xxx@AOL.com"
CopyEmailAddr = "yyy@AOL.com"
Subj = "Test subjject"
Body = "Body"
PathName = "C:\test.txt"

With objMail
.To = EmailAddr
.cc = CopyEmailAddr
.Subject = Subj
.Body = Body
.NoAging = True
.Attachments.Add PathName
.Display
End With

'****** Send the email without prompts *******
SendKeys "%{s}", True
'****************************************************

Set objMail = Nothing
Set objOutlook = Nothing

3 comments:

Anonymous said...

Hey there - thanks for the good tip. I used this in place of my:
.display
.send
coding, and it works great - no more annoying error messages for the 110 reports I send out at the end of each month! I had been using a program that clicked the yes button for me, called "Express ClickYes", but this coding solution is much cleaner and faster.

Thanks again!

Alexis said...

One man said about next tool-dbx file open,this record was on a forum.Why I say about it? This record helped to recover all my mails and it was for free.Moreover software demonstrated how it recovery represents the analysis of separate dbx files.

Alex said...

Today I was at my friend and saw one tool in his PC-fix outlook files.As he said it downloaded it from one soft forum and tool recovered all his damaged mails.Moreover application made it for free and very fast.I'd like it.