PC Review


Reply
Thread Tools Rate Thread

.attachment.add not working - Email to outlook from access

 
 
vavroom@gmail.com
Guest
Posts: n/a
 
      23rd Feb 2006
Hello all,

I hope you can assist.

I found a snipet of code on this group to send email from Access, using
Redemption to get around the Outlook security warnings. All works
well, except for attaching a file.

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

 
Reply With Quote
 
 
 
 
Larry Daugherty
Guest
Posts: n/a
 
      24th Feb 2006
I did something using Redemption a year or two back and had something
I don't see in your code:

Dim objOutlookAttach As Outlook.Attachment

Later in my code this object got repeatedly Set with vile names via
the Attachment.Add

I didn't analyze your code so don's know if you're using the same or
different version, etc.

HTH
--
-Larry-
--

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello all,
>
> I hope you can assist.
>
> I found a snipet of code on this group to send email from Access,

using
> Redemption to get around the Outlook security warnings. All works
> well, except for attaching a file.
>
> 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
>



 
Reply With Quote
 
vavroom@gmail.com
Guest
Posts: n/a
 
      26th Feb 2006
Larry, thanks for the response. I played around a little bit with the
"missing" statement. Either it's not necessary, or I'm too ignorant
about VB to make it work. Likely, the second option is the right one


Still not working, and it's a PITA

 
Reply With Quote
 
vavroom@gmail.com
Guest
Posts: n/a
 
      27th Feb 2006
Interesting. Further testing indicates that the file *does* get
attached, although it doesn't appear listed in the attachments area of
the email.

So, the problem is not attaching the file, but making sure that the
attachment gets displayed in the message. I think at this point it's
not an Access issue, but an Outlook issue... I shall go and ask there.

Thanks

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending email from access with attachment via Outlook Express6 Irshad Alam Microsoft Access VBA Modules 3 4th Feb 2010 02:17 PM
Rcd email with attachment. Click on attachment , Outlook closes Lewis Starr Microsoft Outlook Discussion 0 8th Nov 2008 06:08 PM
How do I unblock a .mdb Access email attachment in Outlook? =?Utf-8?B?Um9iZXJ0IGluIG5lZWQgb2YgYSBHdXJ1?= Microsoft Outlook Discussion 1 17th May 2007 07:13 PM
Outlook receive email with attachment icon but no attachment Nickson Microsoft Outlook Discussion 0 1st Dec 2005 03:52 AM
Opening email with attachment from Access Error (Outlook/Exchange) ReidarT Microsoft Access Form Coding 0 5th Nov 2004 09:02 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:41 PM.