Introduction
This time we will explain how to get all URLS from emails using MS Outlook. Sometimes we need get all URLs from emails. In this post, we will show how to do this. Step by step using SSIS.
Microsoft Graph API is a unified way to access many Microsoft services API including Office 365 API
Prerequisites
Before we perform steps listed in this article, you will need to make sure following prerequisites are met:
- SSIS designer installed. Sometimes it is referred as BIDS or SSDT (download it from Microsoft site).
- Basic knowledge of SSIS package development using Microsoft SQL Server Integration Services.
- Make sure ZappySys SSIS PowerPack is installed (download it).
- Optional (If you want to Deploy and Schedule ) – Deploy and Schedule SSIS Packages
Steps-by-step process to download images from HTML using SSIS
Register Application (OAuth2 App for Graph API)
First, check our article about how to get the OAuth2 connection, click here for the article
Get the information for the body content from the emails
1. Now, Drag and Drop SSIS Data Flow Task from SSIS Toolbox.
2. Double click on the DataFlow task to see the DataFlow designer surface.
3. From the SSIS toolbox drag and drop JSON Source on the dataflow designer surface.
4. Select the OAuth connection you created, then use this URL to get the body content
1 |
https://graph.microsoft.com/v1.0/me/messages?$select=subject,body,bodyPreview,uniqueBody |
5. Drag and drop the trash destination and save the result in a file with the following configuration. Make sure to check the Overwrite target file if exists.
Now we have saved the email body in the file, to extract the links we need to go control flow and drag and drop the Regular Expression Parser Task and follow the steps from below section.
Getting all URLs from emails inside a variable
6. The next step is to save the URLs’. We will use the Regular Expression Parser Task for this.
Also, you need to use Regex and here is one example you can use, in this page Regex101 you can check more details about the expressions we are using:
Expression: href="(.*?)"{{*}}
Save the result in a file of the URLs from emails
7. Finally, use the Logging task to save the URLs in a file, use the following configuration
Conclusion
If everything is OK, you will be able to download the URLS from your emails. To do that, we read the list from the body of the emails. Then we get the URLs of the emails using expressions. Finally, we store them in a local file.