Monday, April 15, 2013

SharePoint 2010 Incoming e-mail Settings on Windows 7



This is copy from original post of Johan Olivier, URL http://johanolivier.blogspot.com/2011/02/sharepoint-2010-incoming-e-mail.html 

(I copied for my easy search and reference)

 Recently I needed to enable a SharePoint 2010 document library to accept incoming emails and then use the data from the body of the email to update list values.
It is really easy to configure SharePoint 2010 for incoming email and to enable a specific document library to receive emails.
You will find a few good tutorials on the web to help you archive this.
One of the very first things which you need to do is to install and configure a SMTP service on your SP2010 web front-end server. That is exactly where I ran into problems as my SP2010 web front end server is running on Windows 7.
Unfortunately Windows 7 does not ship with SMTP Service and almost all the documentation showing how to configure your SP2010 WFE for incoming mail focus on Windows 2008 server.
Many thanks to Wesley Bakker for the clear and helpful instructions which he posted at http://weblogs.asp.net/wesleybakker/archive/2010/08/09/configure-hmailserver-for-sharepoint.aspx
This short tutorial will illustrate how I managed to get my SharePoint 2010 incoming email configured on my Windows 7 web front-end server.
1. Download hMailServer from http://www.hmailserver.com/
2. Install hMailServer and create a new Administrator password when prompted.
3. Configure hMailServer in the following way:
(If I do not specify a setting to be changed then accept the default)
·         After the install completed, add a new domain. You can use anything.
·         In the new hMailServer domain create two new email accounts
[clip_image0024.jpg]
  • Expand Settings and click on SMTP. Set the ‘Local host name’ to your local machine name.
clip_image004
  • Expand ‘Advanced’ and then expand ‘IP Ranges’ and click on ‘Localhost’. I changed the Name, Lower IP, Upper IP values and I removed the requirement for SMTP authentication.
[clip_image0064.jpg] 
  • Because hMailServer does not have an email drop folder by default, you have to create a folder structure to use as a drop folder. I created the following folder structure to use as my drop folder:  C:\Program Files (x86)\hMailServer\Data\JohanSPSDev.local\Dropfolder\
  • Microsoft SMTP server adds header information to emails which hMailServer does not do, so if the information is missing SharePoint will not accept the emails into the library. So in order to prevent this you need to add a script to hMailServer to include the header information into the emails before there are dropped into the drop folder for SharePoint.
  • This process is very clearly explained by Wesley Bakker in his post: http://weblogs.asp.net/wesleybakker/archive/2010/08/09/configure-hmailserver-for-sharepoint.aspx
  • Below is the snippet of that
    • After creating a dropfolder inside the existing hierarchy.(Have a look at the screenshot above). Be sure to set the permissions for this folder to allow the SharePoint Timer Service account to make modifications!
    • Then - after clicking the ‘Show scripts’ button(see screenshot above) - simply open the script file ‘EventHandlers.vbs’ and add the following script.
                Sub OnDeliverMessage(oMessage)
                        Dim path, filename, fso, original, copy
 
                    path = Split(oMessage.Filename, "\", -1, 1)
 
                    filename = "C:\Program Files (x86)\hMailServer\Data\development.com\dropfolder\" & _
                           path(UBound(path))
 
                    Set fso = CreateObject("Scripting.FileSystemObject")
 
                    Set copy = fso.CreateTextFile(filename, True)
                        copy.WriteLine("x-sender: " & oMessage.FromAddress)
                        copy.WriteLine("x-receiver: " & oMessage.To)
 
                    Set original = fso.OpenTextFile(oMessage.Filename, 1)
                        copy.WriteLine(original.ReadAll)
        
                    copy.Close
                    original.Close
                End Sub

    • This should replace the commented Sub OnDeliverMessage(oMessage). Save the script., ‘Check syntax’ to be sure and click ‘Reload scripts’ to enable this freshly added script. The script simply copies ALL incoming mail messages to the ‘dropfolder’ and prepends the two mentioned headers. Now simply point SharePoint to the dropfolder and that’s it!
  • In hMailServer expand ‘Advanced’ and then click on ‘Scripts’.
  • Enable Scripts and click on Show Scripts. Open the existing script file in notepad and add the following text.
  • Ensure to change the drop folder path to your own configuration.
  • After you made the changes save the file and close it.
  • Back in hMailServer click on ‘Check syntax’ and then on ‘Reload scripts’.
clip_image008
4. Test your SMTP Service:
  • Now our hMailServer should be up and running and we are ready to test whether we can send and receive email… because I also have a corporate email account and I have Outlook installed the easiest for me was to create a POP account in Outlook and point it to my new domain.
clip_image010
  • The important thing here is to use an IP address of your local machine instead of using the word localhost or even your pc name. I tried my pc name as well as localhost but when I tested the account settings it kept failing… I only got it to work after I provided the IP address.
  • After I finished configuration of my POP3 account in Outlook I received the following test email in my inbox as confirmation that my SMTP service is working fine
clip_image012
  • So now that our SMTP Service is working the next step is to configure SharePoint.
  • Open Central Administration and go to System Settings.
  • Click on ‘Configure incoming e-mail settings
clip_image014
  • Set ‘Enable sites on this server to receive e-mail’ to ‘Yes’
  • Ensure that you change the e-mail server to match that of the new domain which you created in hMailServer and specify the drop folder which you manually created earlier.
  • Click on OK to save your settings.
clip_image016
  • To test that it is working create a new SP2010 document library and go to the library settings. Click on ‘Incoming e-mail settings’
clip_image018
5. Configure the Incoming e-mail settings for the library:
  • Configure the Incoming e-mail settings for the library as illustrated in the screenshot below and click on ‘OK’ to save the settings. Note that I specify an e-mail address which of an account which I created in hMailServer earlier.
clip_image020
6. Test Everything:
  • Go back to Outlook and select the new POP3 mailbox. Create a new email to be sent from this account and send a test email to the email address of the document library and send the email.
clip_image022
  • After outlook performed a send-receive and the email is in your ‘sent items’ go to SharePoint and refresh the document library.
  • If everything went well you should see the new email in you library.
clip_image024
Note that when a library is configured to accept incoming email SharePoint will automatically add new columns to the library, but the new columns is not automatically added to the default view..so you can modify the view to see the additional information from the email:
clip_image026
You will also notice that the body of the email is not available as a column.
It is very easy to extract the body information by using an eml reader class. I will how you how to do this in a separate post.
Keep in mind that your environment might be very different than mine and there can be a million things configured which might have an impact on getting this to work for you. My anti-virus was not a problem and my hMailServer service was automatically started.
I hope this post will help you to get incoming e-mail configured for SharePoint 2010 on a Windows 7 machine.
Have fun!!

Share:

1 comment: