Create Outlook mail + attachments disappears

dibby44

New member
Local time
Today, 14:11
Joined
Dec 5, 2004
Messages
9
For many years I have used the following vb code to create an Outlook email from Access, add an attachment, and display it in Outlook before sending. Now that I have Office 2007 Pro under Vista HP, it no longer works under Access 2000, nor 2007. Either the process stops after the attachment is created and saved, and the created email disappears, or sometimes I get the Outlook security box, and I click OK to allow access to Outlook and then the email disappears.
Without the attachment, the email is created OK and displays - with an attachment, nothing!

It seems to me that Outlook has some new feature that does not allow remote attachments, but I can't find anything to resolve this problem.

Any help or clues appreciated.
=====================================
MyStr = MSA_SimpleGetSaveFileName3(MyReport)
DoCmd.OutputTo acOutputReport, MyReport,acFormatRTF, MyStr, 0

Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

With objOutlookMsg
Set objOutlookRecipTo = .Recipients.Add(Anyone)
objOutlookRecipTo.Type = olTo
objOutlookRecipTo.Resolve

.Subject = "Any subject"
.Body = "Anything..."
.Importance = olImportanceHigh
.Attachments.Add (MyStr)
.Display
End With
Set objOutlook = Nothing
=========================================
end
 
Sorry guys and girls - still playing around with the code [2 days on] and found an answer [sort of !]. For some odd reason, my assigning the attachment file name to the variable MyStr worked for the export of the file, but was not recognised later in the code for .attachment.add(MyStr)

I amended the variable to MyStr4 in both places, and it works exactly as on the tin!

Keep taking the tablets !
Dave B.
 

Users who are viewing this thread

Back
Top Bottom