Send the form by email by code - InfoPath Dev
in

InfoPath Dev

Send the form by email by code

Last post 10-10-2011 05:36 AM by Brokholm. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 04-17-2008 03:06 PM

    Send the form by email by code

    How can I send the form by e-mail using code?

     (I now that I can using a button, but I want to do this using code)

     

    What I really want is send a specific View by E-mail :)

  • 04-17-2008 03:39 PM In reply to

    Re: Send the form by email by code

    Basically, as a high-level overview, you need to have a Submit to Email data connection already in place. Then you populate the various email fields in code, and submit the connection. 

    However, there are some specific issues you will run into with this... mainly that switching views in code to export or submit a specific view, doesn't work without some specially workarounds. Here are some of the details: http://www.infopathdev.com/forums/t/7655.aspx

  • 04-17-2008 11:53 PM In reply to

    • Albert
    • Top 500 Contributor
    • Joined on 04-03-2008
    • The Netherlands
    • Posts 32

    Re: Send the form by email by code

    There are atleast three ways in InfoPath 2003 to send an email from code (jscript):
     
    //Method one (this also sends the current view)
     
    //Methode two (needs an email dataconnection)
    function EmailWithData(dataAdapterName, to, CC, subject, intro, attachmentFileName)
    {
        try
        {
      var objEmailAdapter;
      objEmailAdapter = XDocument.DataAdapters(dataAdapterName);
            objEmailAdapter.To = to;
            objEmailAdapter.CC = CC;
            objEmailAdapter.Subject = subject;
            objEmailAdapter.Intro = intro;
            objEmailAdapter.AttachmentFileName = attachmentFileName + ".xml";
            objEmailAdapter.Submit();
            return true;
        }
        catch(exception)
        {
            return false;
        }
    }
     
    //Methode three
    XDocument.UI.ShowMailItem(to, CC, BCC, subject, Body);
     
     
    Goodluck, Albert
     
    Filed under: , ,
  • 04-18-2008 05:06 AM In reply to

    Re: Send the form by email by code

     

    Thanks!!

    In my PC I´m having problems of compability with Outlook 2007 and infopath 2003 :/

     But this work in other pc where Outlook 2003 is intalled =D

  • 04-21-2008 04:37 PM In reply to

    Re: Send the form by email by code

    I'm not aware of any incompatibilities between InfoPath 2003 and Outlook 2007. Perhaps someone else can address that issue.

  • 10-10-2011 05:36 AM In reply to

    Re: Send the form by email by code

    Hi

     I know this is an old tread, but I've been having the same, or at least a similar, problem, I've created the form in Infopath 2007, but half the people using the form are still in office 2003. When the form tries to send the current view as a confirmation, they just get at empty mail. Only the subject field is populated, and the email adresses.

    The only way I've been able to make it work is going back to the programming I used when I created an older version of the form in Infopath 2003.

Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.