I have a requirement where I need to fetch data from SQL DB and view/download that content into Microsoft Outlook. DB Table contains various columns like Id, Content, Subject, ToAddress, and other regular information. Content column in this table is in HTML format.
I'm using Angular 6 and Wep API in my application.
I tried multiple approaches but none of them solved my problem:
Approach 1:
Outlook.Application outlookApp = new Outlook.Application();
Outlook.MailItem mailItem = (Outlook.MailItem)outlookApp.CreateItem(Outlook.OlItemType.olMailItem);
mailItem.Subject = message.Subject;
mailItem.To = message.ToEmailAddress;
mailItem.HTMLBody = message.Content;
mailItem.Importance = Outlook.OlImportance.olImportanceLow;
mailItem.Display(true);
For this, email is opening on the server machine but not on the client's machine.
Approach 2:
mailto:stuff@things.com&subject=something&body=<doctype html><span style="color:red">Hi how are you</span>
I can not use this approach, because it is not handling HTML in the email body. I'm using Content data for the email body.
Sample data in Content column:
<style type="text/css">
html {
font-family: Arimo, sans-serif, Calibri (Body);
}
body {
font-family: Arimo, sans-serif, Calibri (Body);
}
label {
font-weight: normal !important;
}
p, div {
font-family: Arimo, sans-serif, Calibri (Body);
}
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
font-family: Arimo, sans-serif, Calibri (Body);
}
footer {
font-family: Arimo, sans-serif, Calibri (Body);
}
</style>
<html>
<body>
<p>Hello</p>
<p>Thank you for using the application</p>
<p>
https://www.google.com
</p>
<p>
This is another paragraph
<br /><br />
Thank you,
<br />
Your DEV Team
</p>
</body>
<footer>
<span style="font-size:x-small;font-style: italic;color:#2b568f">
Note: Please do not reply to this email.
</span>
</footer>
</html>
Thanks in advance