msoutlook.org Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Resend an attachment which is an email

 
Post new topic   Reply to topic    msoutlook.org Forum Index -> Outlook Program VBA
Author Message
Tony29



Joined: 05 Feb 2008
Posts: 4

PostPosted: Tue Feb 05, 2008 2:08 am    Post subject: Resend an attachment which is an email Reply with quote

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 MAILER-DAEMON@xxx.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 MAILER-DAEMON@xxx.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 MAILER-DAEMON@xxx.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

Archived from group: microsoft>public>outlook>program_vba
Back to top
View user's profile Send private message
Michael Bauer [MVP - Outl



Joined: 12 Aug 2007
Posts: 92

PostPosted: Tue Feb 05, 2008 12:03 pm    Post subject: Re: Resend an attachment which is an email Reply with quote

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:


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

> 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 MAILER-DAEMON@xxx.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 MAILER-DAEMON@xxx.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 MAILER-DAEMON@xxx.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
Back to top
View user's profile Send private message
Tony29



Joined: 05 Feb 2008
Posts: 4

PostPosted: Tue Feb 05, 2008 10:47 pm    Post subject: Re: Resend an attachment which is an email Reply with quote

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.

"Michael Bauer [MVP - Outlook]" wrote:

>
>
> 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:
>
>
> Am Mon, 4 Feb 2008 21:08:00 -0800 schrieb Tony29:
>
> > 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 MAILER-DAEMON@xxx.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 MAILER-DAEMON@xxx.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 MAILER-DAEMON@xxx.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
>

Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
Save Attachment via VBA Hello, I have my inbox linked to an Access DB. Is there a way to create a macro that will save an attachment from an e-mail? If so, what would be a difficulty level of completing? Basically, I would like to setup some criteria in access that decides if

Download Email Message Hello, I don't have a option to create Archieve(.PST folder) in my Outlook as it was restricted in our company. I would like to have a macro in outlook which automatically save a copy of the incoming email in my harddisk. So even if i delete the email fro

Email from Word to Outlook Thank you in advance. I'm trying to email a document to Outlook from Word. I have a button in Word that says "Submit". I would like to be able to click that button and it automatically send my Word Doc. to a specific person in Outlook. Can this be done?

How to add an userpropertie to an email folder? Hello, I tried several things but nothing works (create or add an item to the default drafts folder, move the item to the destination folder the item) and then add the The only way to add an userproperty to an email folder is

How to save a email, sent out, as a file Hi, What I need is to save an email which is sent out from MSO as a file, which is a frozen copy of the mail sent. 1. To do the above I need to find out the mail from Sent Items for the mail which was sent out from Outbox. What I know is the EntryId chang
Post new topic   Reply to topic    msoutlook.org Forum Index -> Outlook Program VBA All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group