PC Review


Reply
Thread Tools Rate Thread

Add Attachments to email

 
 
CW
Guest
Posts: n/a
 
      3rd Sep 2003
Gurus-
I am using the following code to send email from Access
2000 through Outlook 2000. While the code itself works
fine, I am stumped as to how I can add a report in
snapshot format as an attachment to the email. Any help
would be very much appreciated.

Sub SendMessage(Optional AttachmentPath)
On Error GoTo Err_Send

Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment


' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")

' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

With objOutlookMsg
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add(Forms!
[frmnewrequest]![Caller])
objOutlookRecip.Type = olTo

' Add the CC recipient(s) to the message.


' Set the Subject, Body, and Importance of the
message.
.Subject = "Request #" & Forms![frmnewrequest]!
[ReqID] & " has been received"
.Body = "Thank you for your recent call to Resource
Planning. Attached you will find the details of the
segments (exceptions) we have entered and/or all requested
skill changes. If you made a request on behalf of another
coach, please ensure they are provided a copy of this
confirmation if they were not included in this
communication. Please ensure that you review the important
notes included in the attachment. If you have any
questions, please feel free to reply to this email or call
us at (360) 756-7155 and reference the request number
listed above. Thank you!" & vbCrLf & vbCrLf
.Importance = olImportanceNormal

' Add attachments to the message.
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Add(AttachmentPath)
End If

' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
End If
Next
.Display

End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing

Exit_Send:
Exit Sub

Err_Send:
MsgBox Err.Description
GoTo Exit_Send

End Sub
 
Reply With Quote
 
 
 
 
Eric Blitzer
Guest
Posts: n/a
 
      3rd Sep 2003
You have a very sophistcated set of code there. I would
use the docmd.sendobject.
Ex

DoCmd.Sendobject acReport, "report name", _
"SnapshotFormat(*.snp)", "JTO@address", _
"JCC@address", "JBCC@address", "subject", "text",
True, ""

Watch out for wordrap
The report name, email addresses, subject and text can all
come from an open form

Eric

>-----Original Message-----
>Gurus-
>I am using the following code to send email from Access
>2000 through Outlook 2000. While the code itself works
>fine, I am stumped as to how I can add a report in
>snapshot format as an attachment to the email. Any help
>would be very much appreciated.
>
>Sub SendMessage(Optional AttachmentPath)
>On Error GoTo Err_Send
>
> Dim objOutlook As Outlook.Application
> Dim objOutlookMsg As Outlook.MailItem
> Dim objOutlookRecip As Outlook.Recipient
> Dim objOutlookAttach As Outlook.Attachment
>
>
> ' Create the Outlook session.
> Set objOutlook = CreateObject("Outlook.Application")
>
> ' Create the message.
> Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
>
> With objOutlookMsg
> ' Add the To recipient(s) to the message.
> Set objOutlookRecip = .Recipients.Add(Forms!
>[frmnewrequest]![Caller])
> objOutlookRecip.Type = olTo
>
> ' Add the CC recipient(s) to the message.
>
>
> ' Set the Subject, Body, and Importance of the
>message.
> .Subject = "Request #" & Forms![frmnewrequest]!
>[ReqID] & " has been received"
> .Body = "Thank you for your recent call to Resource
>Planning. Attached you will find the details of the
>segments (exceptions) we have entered and/or all

requested
>skill changes. If you made a request on behalf of

another
>coach, please ensure they are provided a copy of this
>confirmation if they were not included in this
>communication. Please ensure that you review the

important
>notes included in the attachment. If you have any
>questions, please feel free to reply to this email or

call
>us at (360) 756-7155 and reference the request number
>listed above. Thank you!" & vbCrLf & vbCrLf
> .Importance = olImportanceNormal
>
> ' Add attachments to the message.
> If Not IsMissing(AttachmentPath) Then
> Set objOutlookAttach = .Add(AttachmentPath)
> End If
>
> ' Resolve each Recipient's name.
> For Each objOutlookRecip In .Recipients
> objOutlookRecip.Resolve
> If Not objOutlookRecip.Resolve Then
> objOutlookMsg.Display
> End If
> Next
> .Display
>
> End With
> Set objOutlookMsg = Nothing
> Set objOutlook = Nothing
>
>Exit_Send:
>Exit Sub
>
>Err_Send:
>MsgBox Err.Description
>GoTo Exit_Send
>
>End Sub
>.
>

 
Reply With Quote
 
Cris
Guest
Posts: n/a
 
      3rd Sep 2003
Thanks Eric....however....
I was originally using the SendObject command, but it
doens't allow me to change the senders name or resolve the
email addresses before sending.

Any other ideas?



>-----Original Message-----
>You have a very sophistcated set of code there. I would
>use the docmd.sendobject.
>Ex
>
> DoCmd.Sendobject acReport, "report name", _
> "SnapshotFormat(*.snp)", "JTO@address", _
> "JCC@address", "JBCC@address", "subject", "text",
>True, ""
>
>Watch out for wordrap
>The report name, email addresses, subject and text can

all
>come from an open form
>
>Eric
>
>>-----Original Message-----
>>Gurus-
>>I am using the following code to send email from Access
>>2000 through Outlook 2000. While the code itself works
>>fine, I am stumped as to how I can add a report in
>>snapshot format as an attachment to the email. Any help
>>would be very much appreciated.
>>
>>Sub SendMessage(Optional AttachmentPath)
>>On Error GoTo Err_Send
>>
>> Dim objOutlook As Outlook.Application
>> Dim objOutlookMsg As Outlook.MailItem
>> Dim objOutlookRecip As Outlook.Recipient
>> Dim objOutlookAttach As Outlook.Attachment
>>
>>
>> ' Create the Outlook session.
>> Set objOutlook = CreateObject("Outlook.Application")
>>
>> ' Create the message.
>> Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
>>
>> With objOutlookMsg
>> ' Add the To recipient(s) to the message.
>> Set objOutlookRecip = .Recipients.Add(Forms!
>>[frmnewrequest]![Caller])
>> objOutlookRecip.Type = olTo
>>
>> ' Add the CC recipient(s) to the message.
>>
>>
>> ' Set the Subject, Body, and Importance of the
>>message.
>> .Subject = "Request #" & Forms![frmnewrequest]!
>>[ReqID] & " has been received"
>> .Body = "Thank you for your recent call to

Resource
>>Planning. Attached you will find the details of the
>>segments (exceptions) we have entered and/or all

>requested
>>skill changes. If you made a request on behalf of

>another
>>coach, please ensure they are provided a copy of this
>>confirmation if they were not included in this
>>communication. Please ensure that you review the

>important
>>notes included in the attachment. If you have any
>>questions, please feel free to reply to this email or

>call
>>us at (360) 756-7155 and reference the request number
>>listed above. Thank you!" & vbCrLf & vbCrLf
>> .Importance = olImportanceNormal
>>
>> ' Add attachments to the message.
>> If Not IsMissing(AttachmentPath) Then
>> Set objOutlookAttach = .Add(AttachmentPath)
>> End If
>>
>> ' Resolve each Recipient's name.
>> For Each objOutlookRecip In .Recipients
>> objOutlookRecip.Resolve
>> If Not objOutlookRecip.Resolve Then
>> objOutlookMsg.Display
>> End If
>> Next
>> .Display
>>
>> End With
>> Set objOutlookMsg = Nothing
>> Set objOutlook = Nothing
>>
>>Exit_Send:
>>Exit Sub
>>
>>Err_Send:
>>MsgBox Err.Description
>>GoTo Exit_Send
>>
>>End Sub
>>.
>>

>.
>

 
Reply With Quote
 
Geoff
Guest
Posts: n/a
 
      3rd Sep 2003
Hi Cris

Before running your code to send the email,
could you use the OutputTo method to save the report
to a hard disc file in snapshot format. For example:

DoCmd.OutputTo acOutputReport, _
"MyReportName", acFormatSNP, "C:\MySnapShotFileName"

Good luck!
Geoff


 
Reply With Quote
 
Cris
Guest
Posts: n/a
 
      8th Sep 2003
Geoff-
Great minds think alike! This is exactly what I ended up
doing and it works pretty well, aside from eating up
storage space. This is much more preferable than
listening to my team gripe about the DB.

Thanks again!
CW
>-----Original Message-----
>Hi Cris
>
>Before running your code to send the email,
>could you use the OutputTo method to save the report
>to a hard disc file in snapshot format. For example:
>
>DoCmd.OutputTo acOutputReport, _
> "MyReportName", acFormatSNP, "C:\MySnapShotFileName"
>
>Good luck!
>Geoff
>
>
>.
>

 
Reply With Quote
 
Geoff
Guest
Posts: n/a
 
      9th Sep 2003
Cris

Perhaps also kill the hard disc file after it's been sent (if sending is
fully automated and doesn't need user intervention)?

Regards
Geoff


 
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
Outlook Macro to forward email with pdf attachments to a specified email address nevin009 Microsoft Outlook Discussion 0 14th Apr 2011 06:21 PM
Move or Copy Email Items Creates New Email With Attachments Instea ctc Microsoft Outlook Discussion 1 8th Apr 2010 05:15 PM
Issues w/Email Attachments on Free Service email (Hotmail, Yahoo, Francisco Microsoft Access 1 19th Apr 2008 11:44 PM
forwarding email with attachments - attachments are not there =?Utf-8?B?VGFyYSBhdCBXYWxzaA==?= Microsoft Outlook Discussion 1 30th Apr 2007 09:20 PM
When others forward my email with attachments the attachments won. =?Utf-8?B?bnA=?= Microsoft Outlook Discussion 2 5th Jan 2005 04:21 PM


Features
 

Advertising
 

Newsgroups
 


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