Wednesday, August 1, 2012

How to send emails with styles and embedded images using Pivotal API.

A lot of work.
A lot of projects.
But I've got some free time for Pivotal.

Here is an example how to send formatted emails with styles and embedded images via Pivotal API:

Server Task code:
CdcSoftware.Pivotal.Engine.Mail.EmailMessage emailMessage =
   this.SystemServer.CreateMessage();
emailMessage.To.Add("myemail@email.com");
emailMessage.MimeHtmlBodyFileName = @"C:\Email.htm";
emailMessage.Subject = "Test";
emailMessage.Body = "";
emailMessage.Send();

Email.htm file content:
<html>
 <head>
  <style type="text/css">
   body { 
    background-color:Green;
    font-size: 3em;
   }
  </style>
 </head>
<body>
 Test email:
 <img src="image.jpg"/>
</body>
</html>

Of course, you can save html email templates in database, retrieve their content, save as temp file and then use the code above.
Also it is recommended to use SP 10 or later.

1 comment:

  1. Hi,
    I have question about emails in Pivotal.
    Is it possible to send email with High priority from Pivotal CRM ?

    thanks

    best regards

    Luboš

    ReplyDelete