Resend an attachment which is an email

Resend an attachment which is an email

Post by VG9ueTI » Wed, 06 Feb 2008 14:08:00


There are a lot of questions/answers related to finding and saving
attachments but I think this is a little different.

I receive emails from a site's XXXX@XXXXX.COM indicating that the
email that I sent it could not be delivered. However I know that if I send
my email again it will eventually be delivered. It's just a glitch with
xxx.com.

The email that I receive from XXXX@XXXXX.COM contains as an
attachment the email that I sent in the first place - there is nothing else
that would help me identify the original email that I sent (which by now is
somewhere in my Sent Items folder).

I want to take the attachment from the returned email and simply resend it.

I have so far ...

I have found the email that has been returned by XXXX@XXXXX.COM and
then called ...
Public Sub ProcessUndeliveredResponseFromxxx(eMail As MailItem)

Dim Attachment As Outlook.Attachment
For Each Attachment In eMail.Attachments
If Right(Attachment.FileName, 4) = ".msg" Then

' This is me guessing
Dim NewEmail As Outlook.MailItem
NewEmail = Attachment
NewEmail.Send
Set NewEmail = Nothing
' This is the end of guessing

End If
Next
Set Attachment = Nothing

End Sub

Can someone provide the missing/incorrect logic?

TIA
 
 
 

Resend an attachment which is an email

Post by Michael Ba » Wed, 06 Feb 2008 15:03:38


First, you need to save the attachment as a file; call its SaveAsFile
method. you can then create the MailItem with the CreateItemFromTemplate
function.

--
Best regards
Michael Bauer - MVP Outlook
Outlook Categories? The Tool:
< http://www.yqcomputer.com/ ;

Am Mon, 4 Feb 2008 21:08:00 -0800 schrieb Tony29:

send
else
is
it.

 
 
 

Resend an attachment which is an email

Post by VG9ueTI » Thu, 07 Feb 2008 10:47:00

Thanks for your help - it took me a while to realise that I should use the
saved attachment as the template (sleep helps!) but I got there. Your
suggestion works as follows ...

For Each Attachment In eMail.Attachments
If Right(Attachment.FileName, 4) = ".msg" Then
Attachment.SaveAsFile TempFolder & Attachment.FileName
Set NewItem = Application.CreateItemFromTemplate _
(TempFolder &
Attachment.FileName)
NewItem.Send
eMail.UnRead = False
eMail.Delete
Kill TempFolder & Attachment.FileName
End If
Next

Thanks.