Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

We are trying to leverage Sharepoint 2010 as an internal newsletter mailer within our company. So far we have a document library set up where HTML files are uploaded and then a site page where the files can be browsed at the user's leisure.

There is a workflow in place so that everytime a new HTML file is uploaded to the library, Sharepoint will send out an email to all users in our company with a link to the new news item for viewing.

We would like to use the HTML content as the actual body of the email. So far I have done some digging and haven't found any examples of how to do this. SPD 2010 doesn't seem to have a "document body" or "document content" lookup field in its workflow designer.

Does anyone have an idea of how to accomplish this?

share|improve this question

2 Answers 2

For me, it iss not obvious that internal Emails are really internal. I know a lot of companies using GMail as internal Emails. Or that they are anyway will be opened inside Sharepoint. And HTML of Sharepoint is hardly rendered outside of Sharepoint

I recently dumb followed InfoPath 2010 Lesson 1 - Creating a Basic Form video on youtube in a remote (over RDP) testing machine (which is a virtual machine) of my client.
A simple form was created and after publishing, filling this form and pressing its "Submit your order" button, I entered my GMail address to which box I've got a Email with form (and its XML data).

Here is screenshot of this Email in a web-browser of a machine outside of connection to Sharepoint (and AD):

enter image description here

share|improve this answer
up vote 1 down vote accepted

I ended up solving this issue by creating an event receiver and leveraging C# and the .NET framework to send the email. I threw away the workflow I created earlier.

The receiver's ItemAdded method looked similar to this:

public override void ItemAdded(SPItemEventProperties properties)
{
    base.ItemAdded(properties);

    string html = "";
    using (StreamReader sr = new StreamReader(properties.ListItem.File.OpenBinaryStream()))
    {
        html = sr.ReadToEnd();
    }

    MailMessage message = new MailMessage();
    message.To.Add(new MailAddress("recipient@example.com", "Recipient"));
    message.From = new MailAddress("sharepointmailer@example.com", "Sharepoint Test Emailer");
    message.Subject = "[Sharepoint Emailer Test]: " + properties.ListItem.Title;

    AlternateView htmlView = AlternateView.CreateAlternateViewFromString(html, null, MediaTypeNames.Text.Html);

    message.AlternateViews.Add(htmlView);

    SmtpClient client = new SmtpClient("mail.example.com");
    client.Send(message);
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.