Outlook Looking for macro to save multiple emails as .msg to folder and extracting the invoice ref. from the email body as the filename

Joined
Mar 23, 2019
Messages
3
Reaction score
0
Hi, i am hoping if anyone who know of Outlook macro can help me on this. And for any macro that you can provide, i thank you in advance.

I am looking for a macro that allows me to save multiple selected emails as .msg (at one go), into my C:\ folder. And for each email saved, i need the filename to be different, to pluck the invoice ref. which is found inside the email body. This is how the emails i received looks like. The invoice ref is on the 3rd line. But different company who sent us their emails, sometimes the invoice ref is found on the 4th or 5th line. How to extract this invoice ref as the filename when i save the email :
---------------------------------------------------
To : ABC Co.

Dept : XX team

Ref : 700ERT31

Date : 21-03-19

This is to confirm payment of ........

Please ensure receipt of this.......
----------------------------------------------------
 

Abraham Andres Luna

Child of God
Joined
Mar 14, 2018
Messages
699
Reaction score
227
This is the documentation for the Outlook MailItem class: https://docs.microsoft.com/en-us/office/vba/api/outlook.mailitem
This MailItem has a method called SaveAs that will output the message to the specified folder in a supported format.

So first you have to find the selected emails using the Folder class: https://docs.microsoft.com/en-us/of...s/obtain-and-enumerate-selected-conversations

The MailItem has a Body property that will return the message text, you will have to use regular expressions on that value to extract the Reference number.
 
Joined
Mar 23, 2019
Messages
3
Reaction score
0
This is the documentation for the Outlook MailItem class: https://docs.microsoft.com/en-us/office/vba/api/outlook.mailitem
This MailItem has a method called SaveAs that will output the message to the specified folder in a supported format.

So first you have to find the selected emails using the Folder class: https://docs.microsoft.com/en-us/of...s/obtain-and-enumerate-selected-conversations

The MailItem has a Body property that will return the message text, you will have to use regular expressions on that value to extract the Reference number.
This is the documentation for the Outlook MailItem class: https://docs.microsoft.com/en-us/office/vba/api/outlook.mailitem
This MailItem has a method called SaveAs that will output the message to the specified folder in a supported format.

So first you have to find the selected emails using the Folder class: https://docs.microsoft.com/en-us/of...s/obtain-and-enumerate-selected-conversations

The MailItem has a Body property that will return the message text, you will have to use regular expressions on that value to extract the Reference number.

Hi Luna,

Thank you very much for your reply & the links. As i do not know macro well, i am unable to understand the links. I was hopping someone can provide me a macro that i can just paste into my outlook, with the above request that i need. Have been searching the net fir a macro that fit my request but was unable to find. Thank you again for your reply.
 

Abraham Andres Luna

Child of God
Joined
Mar 14, 2018
Messages
699
Reaction score
227
I do not have Outlook installed so I wouldn't be able to test my code before sending it to you. Finding the perfect macro is going to be tough to do, you will have to find something that is close enough and then have someone modify it so that it's perfect. Try codeproject.com for examples of what you are looking for.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top