Sitecore’s “Send Email Message” save action retains mail server settings

Today I faced an issue with Web Forms for Marketers (WFFM). We had taken a copy of a customer’s system and were trying to test some changes we’d made to it. This involved making sure that the system sent email correctly, and we wanted it to send them to a mail-trap, rather than sending them to actual users. However, when I tried to change the mail server settings, the forms of the system seemed to continue to try to use the customer’s live SMTP server. This was surprising. Continue reading “Sitecore’s “Send Email Message” save action retains mail server settings”

Sitecore’s “Send Email Message” save action retains mail server settings

Enable SSL for sending emails on Sitecore

I was asked to use a GMail server to send emails from Sitecore with. This is actually a pretty reasonable request – but GMail only supports connections over TLS or SSL. Configuring Web Forms for Marketers to use this was proving … interesting, until I found this excellent article by Mark CassidyContinue reading “Enable SSL for sending emails on Sitecore”

Enable SSL for sending emails on Sitecore

Sending Email from Azure with SendGrid

In SharePoint Online I need to send email(s) when a user updates a document. Who this email goes to involves some fairly complex logic – which we’ll ignore for this post. So how do we send the email? SharePoint Online doesn’t allow you to use SPUtility.SendEmail() or System.Net.Mail.SmtpClient – so unless you’re using standard alerts, or the workflow “Send Email” activity, well, you’re going to have to look elsewhere. I didn’t think SharePoint designer Workflows were quite up to the complexity of it, so I started to look elsewhere – at Remote Event Receivers, provider-hosted in Azure.

This leads to the question “can Azure send email?” I can imagine a few reasons why it maybe shouldn’t (think “spam”). Continue reading “Sending Email from Azure with SendGrid”

Sending Email from Azure with SendGrid

HTML 5 – Email Address Validation Regex

And interesting one to stumble upon – the ‘official‘ regex for validating a email address:

Edit: I’ve had to break this down into parts – for some reason WordPress throws a 403 error if I don’t. I think it sees this regex as a security risk!

Before the @ sign:
^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+

The @ sign and after:
@[a-zA-Z0-9-]+(?:.[a-zA-Z0-9-]+)*$

Reads like it should work pretty well to me. I didn’t realise before the @ was so generous. And you could shrink it by using a case insensitive operator.

HTML 5 – Email Address Validation Regex

C# Code to send an email

I’ve been doing some testing of email enabled lists, and I needed to send quite a lot of emails, so I wrote a little console app to do it. Here’s the core of the code I used, in case I need it again, or it’s useful to someone. It uses System.Net.Mail:

SmtpClient smtp = new SmtpClient(@"vm-moss2007.virtual.local");
for (int i = 1; i <= 100; i++)
{
    MailMessage message = new MailMessage("administrator@virtual.local", <a href="mailto:testlist@sharepoint.virtual.local">testlist@sharepoint.virtual.local</a>);
    message.Subject = string.Format("Message {0}", i);
    message.Body = string.Format("This is message '{0}'", i);
    Console.WriteLine("Sending {0}", i);
    smtp.Send(message);
}
C# Code to send an email

Programmatically figure out the Email address of a list

I like mail enabled lists – they’re not perfect, but they are nice, and most folks can handle working email.

Sometimes, though, you want to programmatically create and enable these lists. That’s cool – but how do you figure out the email address of the list afterward?

You can get the first part of the address from the SPList object’s EmailAlias property. But that’s only the bit before the ‘@’ sign – what about the end of the address? Well, you get that from the farm:

emailAlias = list.EmailAlias + "@" + SPFarm.Local.Services.GetValue<SPIncomingEmailService>("").ServerDisplayAddress;

This gets the rest of the address (in my case ‘sharepoint.virtual.local’). Job done.

Programmatically figure out the Email address of a list

Programmatically create and configure Mail Enabled lists

Being able to mail enable a sharepoint list is pretty cool; once enabled an email can receive email, save attachments, etc.. But what’s the address of the lists? How do you enable it? How are attachments stored, and how do we decide who to let email it?

emailsettings

Well, for a customer we wanted to email enable a list with an address based on the site’s title. This meant that the site would have to be created before we could enable the list. So, I stapled a feature to the site’s definition, and used a feature receiver to run my code. Continue reading “Programmatically create and configure Mail Enabled lists”

Programmatically create and configure Mail Enabled lists

Mailing an Active Directory Group

This was something that I set up in our offices, and was trying to set up for a client – but it turned out that there were a few more components involved than I’d first realised.

We have an AD group of ‘All Staff’ which contains, um, all staff. We also have a ‘Company Announcements’ list, and we wanted to send any announcements added to that list to all our staff. As an administrator, I could add an alert for the ‘All Staff’ group ( on the list click List Settings > Alert Me and then enter the group we want to email)

The ‘All Staff group’ is a Mail enabled security group, with it’s own address – e.g. staff@example.com. The puzzle for me (not being an exchange or AD expert) was that in that case, what resolves the addresses? I’d thought that the group being mail enabled meant that you could resolve the email addresses of the users within the group – but what does that? Well, Exchange, as it happens, though I’m not sure how to configure that. The upshot of it is, though, that the AD group you want to mail needs to be mail enabled, and you may need to talk to your exchange guys too.

This is unfortunate, as in a lot of organizations making changes to AD can be a tortuous process. Still, if there is an appropriate group you can email then this is a quick win with things like Announcements lists.

Mailing an Active Directory Group

Custom Email Alert Templates for individual lists

Over time my inbox fills with notes of things I want to blog about – even if just as notes for myself in the future. This was one that I’d forgotten about – you can set an email alert template for an individual list! Really, it’s setting up the Alert Template (in a copy of AlertTemplates.xml), setting that that file can be used for alerts (via STSADM), and then setting that alert template to be used through the object model.

You also get to run a CAML query on the list, and access to the before and after values for items, when filtering what things to send emails about.

It’s all in this very good article.

Custom Email Alert Templates for individual lists