PC Review
Forums
Newsgroups
Microsoft Outlook
Microsoft Outlook VBA Programming
Code to resend mail items
Forums
Newsgroups
Microsoft Outlook
Microsoft Outlook VBA Programming
Code to resend mail items
![]() |
Code to resend mail items |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
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 |
|
|
|
#2 |
|
Guest
Posts: n/a
|
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 > > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

