Delete lines in Outlook

CarFle

New Member
Outlook version
Outlook 2013 64 bit
Email Account
POP3
I am sure this is more than simple but my VBA is very weak and my brain has gone on strike!

Every month I receive a number of emails to forward on to clients.
I select Forward and add the recipient.

I would then like help with a Macro to do the following:

Remove the last word in the Subject line
Delete the first 9 lines of the forwarded email
Delete the last 13 lines
Send

I have tried recording in Word and then fiddling in Outlook but at this stage I am no longer concentrating. Is anyone able to help?

Many thanks
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
For the subject, use the InstrRev function, and search for the first space (" ") beginning from the end of the subject. The function returns the position, which can be used with the Left function to retrieve the text left of that position.

If it's Outlook 2007 or newer, you can use Word's library to edit the body. Here's an example for how to get the Word.Document object from an email: www.vboffice.net/en/developers/use-word-macro-in-outlook

When you have a ref on the Document, Paragraphs(1) refers to the first paragraph, which can be deleted with Paragraphs(1).Range.Delete
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
If there is always something unique in the line you are keeping that you can search for, like Tracking Number: kjgnoeriounvojdnh you could use regex to find it. But if the paragraphs or lines you want to remove are always the first and last, you can remove them instead.
 

dani7ellee77

New Member
Outlook version
Outlook 2010 32 bit
Email Account
POP3
For the subject, utilize the InstrRev capacity, and quest for the main space (" ") starting from the finish of the subject. The capacity restores the position, which can be utilized with the Left capacity to recover the content left of that position.

In the event that it's Outlook 2007 or more up to date, you can utilize Word's library to alter the body. Here's a model for how to get the Word.Document object from an email:

When you have a ref on the Document, Paragraphs(1) alludes to the primary section, which can be erased with Paragraphs(1).Range.Delete
 
Top