PDA

View Full Version : SendObject: works in XP, doesn't work in Vista



DBinPhilly
04-22-2009, 08:01 AM
In a payroll application:
for employees who are getting direct deposit checks we want to email a copy of their check stub to them (formerly we snail-mailed them).

In VBA, I cycle through a list of the direct deposit recipients, and email each one using SendObject.

my problem: works perfectly in Windows 2000/Access 2000
in Windows XP/Access 2003, asks if I really want to do it for each employee
in Windows VISTA/Access 2003: doesn't work at all; get the following error message:
____(application name)____ CAN'T OPEN THE EMAIL SESSION


the command I am using in VBA is:
DoCmd.SendObject acSendReport, stDocName, "SNAPSHOT FORMAT", myEmail,,, mySubject, myMessage, FALSE

where: stDocName = Report Name
myEmail = email Address
mySubject = Outlook Subject Line
myMessage = Outlook Message

We no longer have ANY Windows 2000/ Access 2000 users, so we can't use their machines
We only have 2 remaining Windows XP machines and they are destined for upgrading to Windows VISTA machines

any help would be welcomed, thanx

OBP
04-22-2009, 08:57 AM
The problem appears to be Outlook in Vista, I have been told in the past that you can get Outlook to work with Access by Running Outlook as an Administrator, I have not been able to set this up on my version of Vista. The cause is that outlook looses it's Account Password when run under Vista, in fact I no longer use Outlook and use Vista's Window Mail instead.
It will sometimes work if you open Outlook and set up the Accounts and then try and send without closing Outlook.
If you also can't get it to work try this alternative VBA Code
Dim objOutlook As New Outlook.Application ' outlook object
Dim objMessage As MailItem, strAttach As String ' outlook mail message
DoCmd
strAttach = "c:\Access\West Coast flier.pdf" 'Attachment
Set objMessage = objOutlook.CreateItem(olMailItem)
With objMessage
.To = "Email Address Goes Here"
.subject = "Subject here"
.Body = "This is a Test"
.Attachments.Add strAttach
.Send
End With
Set objOutlook = Nothing
Set objMessage = Nothing