Attachment present, but not showing.

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
 
S

Sue Mosher [MVP-Outlook]

Nothing in your code to create the new message requires Redemption. You can simplify it to:

strSendTo = "(e-mail address removed)"
Const olFormatPlain = 1

Set myOlApp = CreateObject("Outlook.Application")
Set MyItem = myOlApp.CreateItem(0)
With MyItem
' use next statement only in Outlook 2002 or later
.BodyFormat = olFormatPlain
.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

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
V

vavroom

Sue to the rescue! Thanks, it worked.

I knew I didn't need redemption, I didn't know how to get rid of it.
 

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