Microsoft Access can't send this e-mail message (1 Viewer)

davesmith202

Employee of Access World
Local time
Today, 09:45
Joined
Jul 20, 2001
Messages
522
I get the following error when using the SendObject method, trying to send an email using Outlook:

"Microsoft Access can't send this e-mail message"

Is this something to do with setting the references or is it some other problem?

Regards,

Dave
 

spacepro

Registered User.
Local time
Today, 09:45
Joined
Jan 13, 2003
Messages
715
Dave,

It might be your security settings within outlook.

Post the code your using for the sendobject.

Andy
 

davesmith202

Employee of Access World
Local time
Today, 09:45
Joined
Jul 20, 2001
Messages
522
It works on one of my PC's but not the other. The code is below:

Private Sub cmdEmail_Click()
On Error GoTo Err_cmdEmail_Click

Dim strBody As String, strSubject As String, strEmailAddress As String, strFirstName As String, strLastName As String
strEmailAddress = Forms!frmADREnquiriesList!Email
srtSubject = Me.lstTemplates.Column(2)
strBody = CStr(Me.lstTemplates.Column(3))
strBody = DLookup("Body", "tblEmailTemplates", "EmailTemplateID= " & Me.lstTemplates.Column(0))
strFirstName = Forms!frmADREnquiriesList!FirstName
strLastName = Forms!frmADREnquiriesList!LastName
strBody = "Hello " & strFirstName & Chr(10) & Chr(13) & Chr(10) & Chr(13) & strBody

DoCmd.SendObject , , , strEmailAddress, , , srtSubject, strBody

Exit_cmdEmail_Click:
' Exit the sub
Exit Sub

' Error Handler
Err_cmdEmail_Click:
' Check which error occured
Select Case Err
Case 2501 ' SendObject action was canceled
' Resume to the next line and continue
Resume Next
Case Else
' Display the error to the user
MsgBox Err.Description
' Exit the sub
Resume Exit_cmdEmail_Click
End Select

End Sub
 

davesmith202

Employee of Access World
Local time
Today, 09:45
Joined
Jul 20, 2001
Messages
522
Thanks for the link but I can't see a resolution for my problem. There are no articles on Outlook 2003 and that problem.

Is there an alternative to using the SendObject method? What about automation or is that automation?

Regards,

Dave
 

davesmith202

Employee of Access World
Local time
Today, 09:45
Joined
Jul 20, 2001
Messages
522
I don't know what needs changing though! I have two PC's with what I thought was identical setups but I cannot work out why it refuses to work on one of the PC's. It has only had the operating system installed about one month ago aswell.

Dave
 
M

mission2java_78

Guest
davesmith202 said:
I don't know what needs changing though! I have two PC's with what I thought was identical setups but I cannot work out why it refuses to work on one of the PC's. It has only had the operating system installed about one month ago aswell.

Dave

If you're using Outlook, then don't use SendObject, it's very buggy and doesn't really have much useability besides just sending plain text e-mail.

Use outlook automation. Do a search for my user name in the searches, I'm quite certain I've posted how to send an e-mail, a task, an appointment, and meeting notices in Outlook via VB.

Jon
 

davesmith202

Employee of Access World
Local time
Today, 09:45
Joined
Jul 20, 2001
Messages
522
Thanks for the suggestion. I am using the code below but there are two things:

1. I want to preview the message and then click the Send button after I have edited the message.

2. I get a popup saying it could be a virus and a progress bar waiting for me to click yes or no. Can I get rid of this?

Thanks,

Dave

Public Sub SendReport()
On Error GoTo Hell

Dim NameSpace As Object
Dim EmailSend As MailItem
Dim EmailApp As Object
Dim strUser As String

strUser = "myemail@hotmail.com"
Set EmailApp = CreateObject("Outlook.Application") 'using the outlook object
Set NameSpace = EmailApp.GetNamespace("MAPI")
Set EmailSend = EmailApp.CreateItem(0)

EmailSend.Subject = "Here's your report"
EmailSend.Body = "The Report you wanted..."
'EmailSend.Attachments.Add ("source/path")
EmailSend.ReadReceiptRequested = True 'receipt request

EmailSend.Recipients.Add (strUser) 'send to?
EmailSend.Save 'you MUSt save emails with attachments
EmailSend.Send 'send the email

Heaven:
Set EmailSend = Nothing
Exit Sub

Hell:
MsgBox Err.Description, vbCritical, "Error #: " & Err.Number
Resume Heaven

End Sub
 
M

mission2java_78

Guest
To display it use:

EmailSend.Display
and get rid of EmailSend.Send if you plan to send it.


For your second question the answer is no.
Microsoft has this built into the OS and Outlook so that malicious viruses are not sent...so you can't do anything about that.

Jon
 

davesmith202

Employee of Access World
Local time
Today, 09:45
Joined
Jul 20, 2001
Messages
522
When I use the SendObject method, it works without that interruption. But the SendObject method doesn't work on my other PC. This is very frustrating!

Dave
 
M

mission2java_78

Guest
davesmith202 said:
When I use the SendObject method, it works without that interruption. But the SendObject method doesn't work on my other PC. This is very frustrating!

Dave

Thats because sendobject doesnt care about security...it doesnt point back to outlook, it points back to any email MAPI client.

Whats the big deal? Just click yes...its called security.

jon
 

davesmith202

Employee of Access World
Local time
Today, 09:45
Joined
Jul 20, 2001
Messages
522
If I use SendEmail.Display, I don't get that error message. Hurrah!

Dave
 
M

mission2java_78

Guest
davesmith202 said:
If I use SendEmail.Display, I don't get that error message. Hurrah!

Dave

:rolleyes:

its not an error message, its called security

and the reason you dont get it is because access or any program is NOT sending the e-mail, you are now. Make some sense out of it...you have an email object created in your app, you got rid of the EmailSend.Send...therefore your app doesn't really send e-mails, it creates them. The person who sends them is now you...so outlook trusts you.

Jon
 

davesmith202

Employee of Access World
Local time
Today, 09:45
Joined
Jul 20, 2001
Messages
522
That is strange. I deleted a module I had copied and pasted into Outlook and now I am getting that security message again. Damn and blast!

I'm not sure what code was there before so I'm stumped.

Perhaps I should use the Outlook Redemption thing? I've downloaded it but have no idea how to write the code to send a simple email. Anyone got a code snippit to do this?

Also, I ran the installation program. Do I need to register it to the OS somehow? I have seen reference to regsvc or something.

Thanks,

Dave
 
Last edited:

davesmith202

Employee of Access World
Local time
Today, 09:45
Joined
Jul 20, 2001
Messages
522
I ran the reg thing anyway and registered the dll. Do I have to point to anything in Tools, References of MS Access?

I have the code below in an attempt to send an email, but I get the following error:

Compile error: Method or data member not found

When I click ok, it highlights: Public Sub SendEmailTest()

Any ideas?

Dave




Public Sub SendEmailTest()
Set Application = CreateObject("Outlook.Application")


Dim SafeItem, oItem
Set SafeItem = CreateObject("Redemption.SafeMailItem") 'Create an instance of Redemption.SafeMailItem
Set oItem = Application.CreateItem(0) 'Create a new message
SafeItem.Item = oItem 'set Item property
SafeItem.Recipients.Add "somebody@somewhere.com"
SafeItem.Recipients.ResolveAll
SafeItem.Subject = "Testing Redemption"
SafeItem.Display
End Sub
 

dan-cat

Registered User.
Local time
Today, 09:45
Joined
Jun 2, 2002
Messages
3,433
You need to make sure you have set your references to:

Microsoft DAO 3.6 Object library
Microsoft Outlook 9.0/10.0 Object library
Microsoft Office 9.0/10.0 Object library
 

Users who are viewing this thread

Top Bottom