Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / New Users / February 2006

Tip: Looking for answers? Try searching our database.

Outlook not displaying attachment from Access via code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
vavroom@gmail.com - 27 Feb 2006 02:26 GMT
Hello all,

I hope you can assist.

I found a snipet of code on microsoft.public.access to send email from
Access, using
Redemption to get around the Outlook security warnings.  All works
well, except for attaching a file.  Or rather, I *thought* the file
wasn't getting attached.

Further testing indicates that the file does indeed get attached, but
when I preview the email to be sent, the attachment does not get
displayed.  I am using Outlook 2002, and send all my mails in text
format.

Can anyone point me in the right direction to display the attachment?
I know I can tell by the size of the email if there is an attachment,
but my users need to be able to tell which file is being attached.

Thanks

++++

I select the file to attach via a dialogue box, which loads the full
path of the file to attach in txtPath.

Here's my variation on the code, could anyone explain why it won't
attach the files?  And what I need to do to fix it?

Private Sub cmdAEGScience_Click()

 Dim safemail As Variant
 Dim myOlApp
 Dim MyItem
 Dim myRecipient
 Dim myBody
 Dim myfolder
 Dim mynamespace
 Dim myAttachments
 Dim Utils
 Dim strSendTo As String
 Dim strCC As String
 Dim strAttachPath As String
 Dim strAttachPath2 As String
 Dim AEGs As String

AEGs = "bla bla bla"

 strSendTo = Me.cmbPaperCoord
 strCC = Me.txtAddy & "@domain.com"
 strAttachPath = Me.txtPath
 'strAttachPath2 = "FullPathToFile"

 Set myOlApp = CreateObject("Outlook.Application")
 Set MyItem = myOlApp.CreateItem(0)
 Set safemail = CreateObject("Redemption.SafeMailItem")
 Set safemail.Item = MyItem
 Set mynamespace = myOlApp.GetNamespace("MAPI")
 'mynamespace.Logon "myProfile", "myPassword", True, True ' Choose a
Profile
 Set myfolder = mynamespace.GetDefaultFolder(5)
 With safemail
 .Recipients.Add (strSendTo) ' Send To
 .CC = strCC ' Carbon Copy
 .Attachments.Add (strAttachPath) ' Attachment 1
 '.Attachments.Add (strAttachPath2) ' Attachment 2
 .Subject = "AEG - " & Me.txtStuLName & " - " & Me.txtStuID ' Email
Subject Text here
 .Body = AEGs ' Text for Email Body
 '.Importance = olImportanceHigh  ' High importance
 '.ReadReceiptRequested = True
 .OriginatorDeliveryReportRequested = True
 .Display
 '.Send
 End With

 Set Utils = CreateObject("Redemption.MAPIUtils")
 Utils.DeliverNow

 Set myOlApp = Nothing
 Set safemail = Nothing
 Set Utils = Nothing
 'MsgBox "Mail Sent", vbInformation, "Mail Sent..."

End Sub
Sue Mosher [MVP-Outlook] - 27 Feb 2006 14:00 GMT
If you're going to display it and not send it, you may need to save the item first. Furthermore, unless you're planning to invoke Send, I don't see any reason to complicate your code by using Redemption.

FYI, there is a newsgroup specifically for general Outlook programming issues "down the hall" at microsoft.public.outlook.program_vba or, via web interface, at http://www.microsoft.com/office/community/en-us/default.mspx?dg=microsoft.public
.outlook.program_vba


Signature

Sue Mosher, Outlook MVP
  Author of Configuring Microsoft Outlook 2003
    http://www.turtleflock.com/olconfig/index.htm
  and Microsoft Outlook Programming - Jumpstart for
    Administrators, Power Users, and Developers
    http://www.outlookcode.com/jumpstart.aspx

> Hello all,
>
[quoted text clipped - 81 lines]
>
> End Sub
vavroom@gmail.com - 27 Feb 2006 20:24 GMT
Hello Sue,

Note that I commented out the Send, and use Display instead.  Reason
being, users need to be able to see the email before it's sent.  I
haven't outright deleted that line, but likely will later on.

Silly n00b question:  How do I save the item first?

The reason to use Redemption is that my testing shows that whether I
use Send or Display, I get warnings that a third party is trying to
send email via outlook and a dialogue box asking me to allow it from 1
to 10 minutes.  Users may need to send up to 100 emails daily with
this, and just can't afford to have them click yes, twice, for each
email they send.

I'll stroll on over to the group you are mentionning, thanks Sue.
Sue Mosher [MVP-Outlook] - 27 Feb 2006 21:52 GMT
> How do I save the item first?

   .Save

> The reason to use Redemption is that my testing shows that whether I
> use Send or Display, I get warnings

Not with Display, only with Send. Replace this statement:

   .Recipients.Add (strSendTo) ' Send To

with

   .To = strSendTo

and you won't get the address book prompt.

Signature

Sue Mosher, Outlook MVP
  Author of Configuring Microsoft Outlook 2003
    http://www.turtleflock.com/olconfig/index.htm
  and Microsoft Outlook Programming - Jumpstart for
    Administrators, Power Users, and Developers
    http://www.outlookcode.com/jumpstart.aspx

> Hello Sue,
>
[quoted text clipped - 12 lines]
>
> I'll stroll on over to the group you are mentionning, thanks Sue.
vavroom@gmail.com - 27 Feb 2006 23:30 GMT
Sue, I am eternally indepted to you :)  Thank you *so* much.  it works
now and I can ditch redemption!  Huzzah!

Thanks a billion.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.