PC Review Forums Newsgroups Microsoft Outlook Microsoft Outlook VBA Programming Code to resend mail items

Reply

Code to resend mail items

 
Thread Tools Rate Thread
Old 02-03-2005, 04:38 PM   #1
Tony Scholes
Guest
 
Posts: n/a
Default Code to resend mail items


Hi

2nd attempt last post got semi-munched!

I've a need for a macro that will resend selected mail items to a specific
address without modifying the email body, subject or the sender.. Rather
like the "Resend This Message" button but without all the questions, and
something that I can use to resend (say) 20 messages at a time

So I have something like this :-

Sub SendToSpamTrap()
Dim objOL As Outlook.Application
Dim objMsg As Outlook.MailItem 'Object
Dim objMsgCopy As Outlook.MailItem
Dim objSelection As Outlook.Selection

Set objOL = CreateObject("Outlook.Application")
Set objSelection = objOL.ActiveExplorer.Selection

For Each objMsg In objSelection
If objMsg.Class = olMail Then
Set objMsgCopy = Application.CreateItem(0)
objMsgCopy.Body = objMsg.Body
objMsgCopy.To = "Spamtrap"
objMsgCopy.CC = ""
objMsgCopy.BCC = ""
objMsgCopy.SenderName = objMsg.SenderName
objMsgCopy.Subject = objMsg.Subject
If objMsg.GetInspector.EditorType = olEditorHTML Then
objMsgCopy.HTMLBody = objMsg.HTMLBody
Else
objMsgCopy.Body = objMsg.Body
End If
objMsgCopy.Send
End If
Next
End Sub

This I assign to a button on the task bar...

Anyway, I have 2 problems :-

1. I can't change the sender name, it always comes from me, and attempts
to modify the SenderName property fail since it's read only... I need it to
come from the original sender.
2. If the body isn't HTML then it always get's set to RTF (even if the
original is plain text) and you can't change it since the EditorType
property is readonly.

This is Outlook 2000, no Exchange server involved...

Any clues? All help appreciated...

--
Tony Scholes
tonys@beacon.co.uk


  Reply With Quote
Old 03-03-2005, 07:19 AM   #2
Michael Bauer
Guest
 
Posts: n/a
Default Re: Code to resend mail items

Hi Tony,

you could add the original sender to the ReplyRecipients collection. And
instead of copying each property step by step just call
objMsgCopy = objMsg.Copy.

--
Viele Grüße
Michael Bauer


"Tony Scholes" <tony.scholes@beacon.co.uk> wrote in message
news:d04rg5$fag$1@news.tiscali.fr...
> Hi
>
> 2nd attempt last post got semi-munched!
>
> I've a need for a macro that will resend selected mail items to a

specific
> address without modifying the email body, subject or the sender..

Rather
> like the "Resend This Message" button but without all the questions,

and
> something that I can use to resend (say) 20 messages at a time
>
> So I have something like this :-
>
> Sub SendToSpamTrap()
> Dim objOL As Outlook.Application
> Dim objMsg As Outlook.MailItem 'Object
> Dim objMsgCopy As Outlook.MailItem
> Dim objSelection As Outlook.Selection
>
> Set objOL = CreateObject("Outlook.Application")
> Set objSelection = objOL.ActiveExplorer.Selection
>
> For Each objMsg In objSelection
> If objMsg.Class = olMail Then
> Set objMsgCopy = Application.CreateItem(0)
> objMsgCopy.Body = objMsg.Body
> objMsgCopy.To = "Spamtrap"
> objMsgCopy.CC = ""
> objMsgCopy.BCC = ""
> objMsgCopy.SenderName = objMsg.SenderName
> objMsgCopy.Subject = objMsg.Subject
> If objMsg.GetInspector.EditorType = olEditorHTML Then
> objMsgCopy.HTMLBody = objMsg.HTMLBody
> Else
> objMsgCopy.Body = objMsg.Body
> End If
> objMsgCopy.Send
> End If
> Next
> End Sub
>
> This I assign to a button on the task bar...
>
> Anyway, I have 2 problems :-
>
> 1. I can't change the sender name, it always comes from me, and

attempts
> to modify the SenderName property fail since it's read only... I need

it to
> come from the original sender.
> 2. If the body isn't HTML then it always get's set to RTF (even if

the
> original is plain text) and you can't change it since the EditorType
> property is readonly.
>
> This is Outlook 2000, no Exchange server involved...
>
> Any clues? All help appreciated...
>
> --
> Tony Scholes
> tonys@beacon.co.uk
>
>


  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off