Sending emails (1 Viewer)

kadara

Registered User.
Local time
Today, 09:01
Joined
Jun 19, 2010
Messages
43
Hi,

I would like to send an email with the following code:

Code:
DoCmd.SendObject , , , strTo, , , strSubject, strText, False

My question is: When I click "No" on the message box "A program is trying to automatically send e-mail on your behalf. Do you want to allow this?" I get a runtime error (2293: sending emails for Access can't send this e-mail message). How could I disable this runtime error message and put another messagebox made by me (I know little about error handling)?
Please help. Thanks.
 

DCrake

Remembered
Local time
Today, 07:01
Joined
Jun 8, 2005
Messages
8,632
There are plenty of threads on subject on the forum, do a search for the solutions.
 

kadara

Registered User.
Local time
Today, 09:01
Joined
Jun 19, 2010
Messages
43
I did a search and I found the following code:

Code:
On Error GoTo MyButton_err

' your code here

MyButton_Exit:
   Exit Sub

MyButton_err:
If Err.Number <> 2293 Then
   MsgBox Err.Description, vbExclamation, "Error #: " & Err.Num
End If
Resume MyButton_Exit

but I still have the same problem.
I appreciate any kind of help.
 

John Big Booty

AWF VIP
Local time
Today, 16:01
Joined
Aug 29, 2005
Messages
8,263
You have initiated code to automatically send an email. So why would you then go and answer "No" to a warning that a program is trying to send email when you are the person who initiated the process in the first place :confused:

Have a look at this article for possible solutions.
 

pnevilm

New member
Local time
Yesterday, 23:01
Joined
Oct 9, 2010
Messages
4
I used to get this same message due to the security settings in Outlook. Change your security settings. I am using Access 2007, and the code I use to send a standard email with attachements is:

Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment

' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("the TO email address goes here")
objOutlookRecip.Type = olTo
' Add the CC recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("your FROM email address goes here")
objOutlookRecip.Type = olCC
' Set the Subject, Body, and Importance of the message.
.Subject = "subject name"
.Body = "body of email" & vbCrLf & vbCrLf
.Importance = olImportanceHigh 'High importance

' Add attachments to the message.
Set objOutlookAttach = .Attachments.Add

' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
End If
Next
.Send
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
End Sub
 

darbid

Registered User.
Local time
Today, 08:01
Joined
Jun 26, 2008
Messages
1,428
How could I disable this runtime error message and put another messagebox made by me (I know little about error handling)?
Please help. Thanks.
Hi Kadara,

Start with this link http://www.outlookcode.com/article.aspx?ID=52 then work around with the links that come off it. This will give you a better understanding of what you are dealing with.

The issue is that Microsoft in an update to Office 2003 stopped VBA programs (and ALMOST 100% of other languages ) from automatically sending emails, in an attempt (in my opinion very weak attempt) to curb viruses sending emails. All that it stopped was people like you and I (viruses still do this and a lot worse to Windows computers) and made a lot of money for the developer of for example Redemption to sell a program which does exactly what Microsoft stopped.

Now with 2007 and 2010 there are numerous workarounds (still you can buy Redemption :) ) The first is to lower your security level for programs like VBA to run on the PC. If you are in an administered environment this is going to be difficult.
 

Users who are viewing this thread

Top Bottom