Fetch, edit and forward an email with VBA outlook

lillyfrilly

New Member
Outlook version
Outlook 2021 64 bit
Email Account
Office 365 Exchange
Hello everyone I have never used VBA and I was assigned a task at work, but I can't complete it, so I thought I would ask for your help.

What they asked me to do is:
1)Fetch from the inbox (adc@gmail.it) only some emails (to recognize them I noticed that these emails in the body contain "Ticket information" ->but this I think can be done by applying a rule to the inbox).
2)The body of the email should be modified by removing hidden tags (which are always in the last two lines).
3)Forward that email (by removing the header that is generated when forwarding an email) from a mailbox (def@gmail.it) to the initial mailbox abc@gmail.it

Could you please help me, I hope I was clear in my explanation.
 
The macros on this page will get you halfway there - "Find a code in the message body, then forward" would be the closest and need less customization. They use rules but can be converted to an itemadd macro to watch the mailbox. Either way, it only runs when Outlook is open.
Run a Script Rule: Forwarding Messages

If you use the rule method - it looks for the condition- ticket information - and then calls up a script, removes the hidden content and sends it.

Do you need to include the last two lines without the hidden tags or can the lines be removed?

The easiest way to remove the message header - From, to, subject, date - from the forward is to copy the body and paste it in the Forward. If you don't need the last 2 lines, it might be possible easier to copy all but the last two. Or it might work to paste as plain text, if there are no hyperlinks you need to keep.
 
The macros on this page will get you halfway there - "Find a code in the message body, then forward" would be the closest and need less customization. They use rules but can be converted to an itemadd macro to watch the mailbox. Either way, it only runs when Outlook is open.
Run a Script Rule: Forwarding Messages

If you use the rule method - it looks for the condition- ticket information - and then calls up a script, removes the hidden content and sends it.

Do you need to include the last two lines without the hidden tags or can the lines be removed?

The easiest way to remove the message header - From, to, subject, date - from the forward is to copy the body and paste it in the Forward. If you don't need the last 2 lines, it might be possible easier to copy all but the last two. Or it might work to paste as plain text, if there are no hyperlinks you need to keep.

Hi Diana meanwhile thank you for the feedback,
unfortunately having a short deadline and never having used VBA before I am in a lot of trouble.
Would you happen to be able to show me how to set up the whole macro please?
 
Similar threads
Thread starter Title Forum Replies Date
H Preventing the 'email address fetch from Exchange' crashing email reading code Exchange Server Administration 0
A Script to fetch data from mails in restricted collection and sending them to excel Using Outlook 1
P How to fetch ALL (not only Inbox) emails from Hotmail/live server (by POP3)? Using Outlook 1
I Outlook will not fetch or send emails after changes to Win .Net Framework prog Using Outlook.com accounts in Outlook 2
H using VBA to edit subject line Outlook VBA and Custom Forms 0
J Cannot edit a calendar event received as an invitation Using Outlook 2
E Edit incoming emails to remove a certain sentence added by the "system" Using Outlook 1
B Outlook 2019 Custom Email form - Edit default email form Outlook VBA and Custom Forms 6
Witzker Outlook 2019 Edit contact from email does not open the user defined contactform Using Outlook 3
T Outlook 2010 Cannot edit Calendar entries in OL 2010. Using Outlook 1
G print attachment straight away; working script edit not working Outlook VBA and Custom Forms 0
A Edit attachment Save and Reply Outlook VBA and Custom Forms 0
F VBA code to dock Styles whenever I write or edit an email Outlook VBA and Custom Forms 0
J Edit auto-complete list in Outlook 2016+/365? Using Outlook 0
J Message search and edit, another way? Outlook VBA and Custom Forms 4
A Edit subject - and change conversationTopic - using VBA and redemption Outlook VBA and Custom Forms 2
L Wierd Office 365 Contact unable to edit body of random contacts Using Outlook 5
N VBA Script to Open highlighted e-mail and Edit Message Outlook VBA and Custom Forms 5
S Unable to Edit Contact Information in Certain Contact Folders Using Outlook 3
S Outlook.com cannot edit some contacts Using Outlook.com accounts in Outlook 5
D Edit Subject (Multiple Accounts) Outlook VBA and Custom Forms 5
B My outlook calendar edit issue Outlook VBA and Custom Forms 0
D VBA to edit body of incoming email and forwarding it Outlook VBA and Custom Forms 11
Diane Poremsky Edit and Save Outlook's Read-Only Attachments Using Outlook 0
P "Edit Message" feature removed in Outlook 2016 for Mac Outlook VBA and Custom Forms 0
snissen Where is "Edit Message" in Outlook 2016? Using Outlook 2
P People/Contact Record gets deleted when I edit it? Using Outlook 3
C Edit/Create Pen Not Working Outlook 2013 Using Outlook 1
X Bulk edit Contact forms Using Outlook 2
A Contact address disappears when opened to edit Using Outlook 5
J Can invitee edit details? Using Outlook 1
R Edit Subject Line of Meeting Invitation? Using Outlook 1
G Outlook 2013: Cannot Edit default Holiday Calendar Using Outlook 2
V Custom form won't open for edit Outlook VBA and Custom Forms 3
M Bulk Edit contact notes BCM (Business Contact Manager) 1
P Edit Subject for every sent message Outlook VBA and Custom Forms 3
M Any way to edit the message field on a 2010 Outlook Form? Using Outlook 3
S OL 2010 shortcut to edit received mail Using Outlook 3
A Cannot edit or open existing contact nor add new ones. BCM (Business Contact Manager) 1
T Exchange 2010: 'could not save item' and 'Unknown error' when edit calendars Exchange Server Administration 1
M Outlook 2003: Cannot edit default Contact Form Using Outlook 11
S how can i edit email address/es from the from field Using Outlook 5
M How to edit a monthly calendar to remove the cover page Using Outlook 1
S How do I edit an attachment in an invite without notifying the attendees? Using Outlook 2
B Notice to user of appt. set by person with permission to edit (Outlook 2003) Using Outlook 7
H Edit email message Using Outlook 7
F Text Format Change - Bulk Edit Contact Notes Using Outlook 2
T Unable to edit Distribution Group membership via Outlook (works via ECP). Exchange Server Administration 7
D How do I edit a macro in Outlook? Outlook VBA and Custom Forms 1
E Currency Edit Control on custom Taskpanes Outlook VBA and Custom Forms 1

Similar threads

Back
Top