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

I want to send e-mail from an InfoPath (2007/2010) form (InfoPath client, NOT web hosted). I found two ways that look promising:

  1. using System.Web.Mail.MailMessage class (http://vspug.com/ssa/2006/01/03/sending-email-from-infopath-using-managed-code/)
  2. using Microsoft.Office.Interop.Outlook.MailItem

    Application application = new ApplicationClass(); application.GetNamespace("MAPI"); MailItem mailItem = (MailItem)application.CreateItem(OlItemType.olMailItem); mailItem.Subject = subject; // ... mailItem.Send();

What is the way to go and why?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

The Office Outlook Interop assumes Outlook is installed and configured on the client, the System.Web.MailMessage does not, but was designed to be used from server web applications.

share|improve this answer
    
So, if the form is browser hostet, I should use the first approach, and if it is hosted in InfoPath client, I should go with the second? Is there a way to be independent from the fact, where the form is hosted? –  Hinek Jul 21 '11 at 9:24
1  
Unless you are certain that your users are actively using Outlook on the desktop avoid using the Interop assemblies. System.Web.Mail is fine to use server or desktop, but has some potential issues with legacy OS (XP, Windows Server 2003) due to dependencies - most of the time it should work fine. –  Chris Beckett Jul 21 '11 at 15:47
    
Thanks, that clarified it for me. –  Hinek Jul 25 '11 at 6:39
add comment

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.