in

InfoPath Dev

Submit a form to a email data connector in C#?

Last post 06-05-2008 08:18 AM by InfoPathN00b. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 06-04-2008 07:57 AM

    Submit a form to a email data connector in C#?

    I need to submit a form to a email data connector in code (I'm using C# in InfoPath 2007). This article

    How To: Submit Data as an E-mail Message
    http://msdn.microsoft.com/en-us/library/bb250998.aspx

    gives an example (in VB) using the EmailAdapter which references the data conenction but I can't find any C# equivalent (the rest of my code is in C#). I have also found http://www.sharepointblogs.com/ssa/archive/2006/01/03/sending-email-from-infopath-using-managed-code.aspx but I don't want to submit it as a raw SMTP message as it needs to go through Outlook. Can anyone point me in the right direction here, I just need a simple example.

     

    Update: I've found this code:

    EmailAdapter oEmail = (EmailAdapter)thisXDocument.DataAdapters["Submit Email"];
    oEmail.To = strTo;
    oEmail.CC = sCCAddress;
    oEmail.Subject =strSubject;
    oEmail.Intro = strMessage;

    oEmail.Submit();

    here http://www.infopathdev.com/forums/t/1636.aspx?PageIndex=1 which apparently should work in C# but I get an error The type or namespace name 'EmailAdapter' could not be found (are you missing a using directive or an assembly reference?)
    and
    The name 'thisXDocument' does not exist in the current context
    Also I need to atatch the form data can I do that using this method?

    Filed under: ,
  • 06-05-2008 08:18 AM In reply to

    Re: Submit a form to a email data connector in C#?

    I couldn't find a solution to the The name 'thisXDocument' does not exist in the current context error and foudn a different way of doing it using the Mail Envelope class from http://msdn.microsoft.com/en-us/library/microsoft.office.infopath.mailenvelope.aspx but now am getting

    Error    1    The type or namespace name 'MailEnvelope' does not exist in the namespace 'Microsoft.Office.InfoPath' (are you missing an assembly reference?)

    Error    2    'Microsoft.Office.InfoPath.Application' does not contain a definition for 'ActiveWindow'

    I have the following usage directives

    using Microsoft.Office.InfoPath;
    using System;
    using System.DirectoryServices;
    using System.Xml;
    using System.Xml.XPath;
    using System.Net.Mail;
    using System.Windows.Forms;

    and I know the references are the same can anyone tell me what I'm missing, I had it working before but changed something (I don't know what).

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