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?


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.

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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