How to Open an Outlook Email From Dynamics 365 Finance and Operations
Creating a starting template for an email in Dynamics 365 Finance and Operations lets you add additional emails and modify content from your ERP environment.
Recently we had a client ask how to do this, so I have worked up a quick and simple guide for you to follow if you want to do the same.
To open an Outlook email from Dynamics 365 you can use the following code. In this code, we're using a basic "mailto" and the browser class to open the "mailto".
It's important to note there are three potential pitfalls with this:
- The computer you are trying to use this on has to have Outlook installed or it won't work.
- Your browser may attempt to block the pop-up. You'll need to allow it.
- The first time you run this, it will ask you how to open it. You can either check or uncheck the box that says "Always do whichever option you pick." For example, if it offers you a browser or Outlook, you can check the box of the one you'd prefer it use.
Here is the code:
final class SSI_SendEmail { public static void sendEmail(str _to, str _subject, str _body = '') { //This creates the base strings we need for the mail to str mailTo = 'mailto:%1?subject=%2'; str body = '&body=%1'; //Initialize the browser Browser browser = new Browser(); //Put the mailto together with the appropriate variables. str openEmail = strFmt(mailTo, _to, _subject); if(_body != '') { body = strFmt(body, _body); openEmail = strFmt('%1%2', openEmail, body); } //Launch the mailto. browser.navigate(openEmail); } }
Want to Learn More About Custom Solutions in Dynamics 365 Finance and Operations?
Get in touch with us! Our team is ready to work with you on your request and come up with creative solutions to help your business run better.
Under the terms of this license, you are authorized to share and redistribute the content across various mediums, subject to adherence to the specified conditions: you must provide proper attribution to Stoneridge as the original creator in a manner that does not imply their endorsement of your use, the material is to be utilized solely for non-commercial purposes, and alterations, modifications, or derivative works based on the original material are strictly prohibited.
Responsibility rests with the licensee to ensure that their use of the material does not violate any other rights.