V
vavroom
I'm revisiting an issue that I had in January. At the time Sue
suggested a possible solution, but either I wasn't sure how to
implement it, or it wasn't working (most probably #1).
I am trying to send email with an attached file from Access. I have a
command button that creates a CSV file, which should then be attached
to an email. The email should open for the sender to review before
actually sending.
The code works, except that when the outlook message is opened, the
Attachment field doesn't show. When email is sent, the file *is*
attached.
Here's the code used to actually send the file (note, not mine,
scavenged from elsewhere).
===
Dim safemail As Variant
Dim myOlApp
Dim MyItem
Dim myRecipient
Dim myBody
Dim myfolder
Dim mynamespace
Dim myAttachments
Dim Utils
Dim strSendTo As String
strSendTo = "(e-mail address removed)"
Set myOlApp = CreateObject("Outlook.Application")
Set MyItem = myOlApp.CreateItem(0)
Set safemail = CreateObject("Redemption.SafeMailItem")
Set safemail.Item = MyItem
Set mynamespace = myOlApp.GetNamespace("MAPI")
Set myfolder = mynamespace.GetDefaultFolder(5)
With safemail
.To = strSendTo
.Attachments.Add (strCSVExport) ' Attachment 1
.Subject = "New CFCW Applications - " & Date ' Email Subject Text
here
.Body = "Latest batch of CFCW applications" ' Text for Email Body
.Display
End With
Set Utils = CreateObject("Redemption.MAPIUtils")
Utils.DeliverNow
Set myOlApp = Nothing
Set safemail = Nothing
Set Utils = Nothing
===
Sue had suggested that maybe to show the attachment it needed to be
saved first, and pointed out that I should use .Save for that. Alas,
not sure where that statement would go, I tried in many places, no
effect.
Any ideas on how to get the actual attachment to appear in the
attachment field in the message before sending it?
thanks
suggested a possible solution, but either I wasn't sure how to
implement it, or it wasn't working (most probably #1).
I am trying to send email with an attached file from Access. I have a
command button that creates a CSV file, which should then be attached
to an email. The email should open for the sender to review before
actually sending.
The code works, except that when the outlook message is opened, the
Attachment field doesn't show. When email is sent, the file *is*
attached.
Here's the code used to actually send the file (note, not mine,
scavenged from elsewhere).
===
Dim safemail As Variant
Dim myOlApp
Dim MyItem
Dim myRecipient
Dim myBody
Dim myfolder
Dim mynamespace
Dim myAttachments
Dim Utils
Dim strSendTo As String
strSendTo = "(e-mail address removed)"
Set myOlApp = CreateObject("Outlook.Application")
Set MyItem = myOlApp.CreateItem(0)
Set safemail = CreateObject("Redemption.SafeMailItem")
Set safemail.Item = MyItem
Set mynamespace = myOlApp.GetNamespace("MAPI")
Set myfolder = mynamespace.GetDefaultFolder(5)
With safemail
.To = strSendTo
.Attachments.Add (strCSVExport) ' Attachment 1
.Subject = "New CFCW Applications - " & Date ' Email Subject Text
here
.Body = "Latest batch of CFCW applications" ' Text for Email Body
.Display
End With
Set Utils = CreateObject("Redemption.MAPIUtils")
Utils.DeliverNow
Set myOlApp = Nothing
Set safemail = Nothing
Set Utils = Nothing
===
Sue had suggested that maybe to show the attachment it needed to be
saved first, and pointed out that I should use .Save for that. Alas,
not sure where that statement would go, I tried in many places, no
effect.
Any ideas on how to get the actual attachment to appear in the
attachment field in the message before sending it?
thanks