Archive

Archive for September, 2010

Setup incoming email for your SharePoint development VM

September 3, 2010 Leave a comment

So today I was trying to figure out how to debug an event handler on an email-enabled list.  My dev environment is running on a VM on my laptop so I didn’t really have an exchange server I could hook up to.  So, configuring the SMTP service on my Windows 2008 machine was the way to go.

In server manager, under features, click Add Feature, then select the SMTP service.  Accept the feature dependencies and finish the install.



Open the IIS 6.0 manager, and right-click your new SMTP Virtual Server node, then click properties.  Under access, ensure your authentication method is set to annonymous and your relay restrictions allow anyone.  Remember, this is just a development setup, so hopefully noone will be hacking into your new SMTP server to send out spam for Viagra.

Also, you may want to assign an alias for your domain, but that’s not required.

Next, go into Central Administration -> System Settings -> Configure incoming e-mail settings.  Select advanced settings, and at the bottom plug in your machine name and the email drop folder ‘c:\inetpub\mailroot\drop’ then hit OK.

Once that’s done we just need to enable the list to receive emails.  Just open your list (or create a new one) and go to list settings.  Under the communication section is a link for Incoming e-mail settings.  Select that and choose the settings appropriate for your list.  Note that you may want to configure this through a feature receiver or a list deployed in your solution (after all, isn’t that what we’re here for?).

Now lets deploy and debug our event receiver.  In your Visual Studio solution, click run to deploy and begin debugging the solution.  Now, although normal list event receivers are run on the w3wp.exe process, list event receivers running on e-mail enabled lists will be run by the OWSTIMER.EXE process, so use the Debug -> Attach to Process… option to find it.  You may need to check the Show processes from all users option.

Once we’ve got our event wired up and the proper process being debugged, we just need to fire up and email and see if this thing works.  So, unless you have an email client (or want to install one) on your virutal machine, back out to your host machine.  You’ll need to make sure that your host machine can connect to your VM over the network.  Now, in Outlook, go to Tools -> Account settings… In the email tab, click on New… and select the Microsoft Exchange, POP3, IMAP or HTTP option.  On the next screen, don’t enter anything, but check the box at the bottom of the screen specifying that you want to manually configure your settings, and next choose the Internet email option.

On the next screen you’ll be asked for a bunch of settings for the SMTP server, your email address, user name and password. The important thing here is to set the SMTP server to your VM server address, we don’t have a POP3 or IMAP server set up on the machine, so incoming mail won’t work, but that shouldn’t matter since we just want to send mail to our new SMTP server.  Enter in some test email, and the username and password of your development user.  Click the Test Account Settings… button and you should receive the results I got below.

If you didn’t, it’s most likely because your VM isn’t responding at the address you plugged in for your Outoing mail server (SMTP) value.  Remember, this value doesn’t need to have the domain your VM is on, it just needs to be able to find the SMTP service at that address.  One extra way to test it is to open the mail drop folder (c:\inetpub\mailroot\drop) on your VM and watch the test email file show up there, then promptly disappear when the timer job runs.

Now just create a new email and send it to your new list email address – be sure to use the new account you just created.  Type in your subject and email body and send away.

Advertisements
Categories: SharePoint