SendObject problems

P

Pastor Del

It has come to my attention that my Access 2000 applications can not send an
email with SendObject when the user is running Outlook as administrator in
Vista or above. Does anyone have a work around for this? My company has
many computers that use these applications and we are gradually upgrading to
Windows 7.
 
B

Brian

I have not seen that issue because I do not work with that particular
combination of OS & Access. However, I recently replaced some of my
SendObject code with Outlook automation code instead (so I could send
attachments), with very good results. It might be worth testing this, and the
Microsoft link below made the move to Outlook automation very easy:

http://support.microsoft.com/kb/161088
 
P

Pastor Del

The article you referenced is for Access 97. Is that what you are using? I
need my applications to send emails in Access 2000, 2003 & 2007
 
D

Douglas J. Steele

That code should work with any version of Access, and any version of
Outlook.

The only change you'll have to make is in step 5: the version of Outlook
will vary (9.0 for 2000, 10.0 for 2002, 11.0 for 2003, 12.0 for 2007)

In fact, you can improve on that code signficantly by using Late Binding
instead, so that you don't need to set a reference to any version of
Outlook.

Sub SendMessage(DisplayMsg As Boolean, Optional AttachmentPath)
Const olMailItem As Long = 0
Const olTo As Long = 1
Const olCC As Long = 2
Const olBCC As Long = 3
Const olImportanceHigh As Long = 2

Dim objOutlook As Object ' Outlook.Application
Dim objOutlookMsg As Object ' Outlook.MailItem
Dim objOutlookRecip As Object ' Outlook.Recipient
Dim objOutlookAttach As Object ' 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("Nancy Davolio")
objOutlookRecip.Type = olTo

' Add the CC recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("Michael Suyama")
objOutlookRecip.Type = olCC

' Add the BCC recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("Andrew Fuller")
objOutlookRecip.Type = olBCC

' Set the Subject, Body, and Importance of the message.
.Subject = "This is an Automation test with Microsoft Outlook"
.Body = "This is the body of the message." & vbCrLf & vbCrLf
.Importance = olImportanceHigh 'High importance

' Add attachments to the message.
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
End If

' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next

' Should we display the message before sending?
If DisplayMsg Then
.Display
Else
.Save
.Send
End If
End With

Set objOutlook = Nothing

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top