Forwarding email and replacing body

Status
Not open for further replies.

Amy2704

New Member
Outlook version
Outlook 2010 64 bit
Email Account
Outlook.com (as MS Exchange)
Morning,

I am wanting to to create a VBA which will amend the body of a email before it is forward via rules.

The emails are coming from specific addresses. I need to be able to pick these emails up, amend the wording and then forward them. I don't want the forwarding information in the email that is getting sent.

As the original email was forwarded and then i forward the email again it shows it has been forward twice. I want this removing and inserting some text of my own.

Can anyone please advise. I am very very new to Outlook VBA.

Thank you
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
i have several sample scripts at slipstick.com - this is one - Run a Script Rule: Change Subject then Forward Message

if you wanted to forward the exact message you received, you'd use


Sub ChangeSubjectForward(Item As Outlook.MailItem)
Set myForward = Item.Forward
myForward.Recipients.Add "alias@domain.com"
myForward.body = item.body
myForward.Send
End Sub

if you need to edit the message, you need to use instr/mid functions or regex to strip out the previous forward header. if the subject is always identical, you could use something like this to get the body:
int = InStr(1, item.body, "subject-name")
strbody = right(item.body, len(item.body) - int)
myForward.body = strbody

if it's an html message, you may need to use .htmlbody instead of .body
 
Status
Not open for further replies.
Top