Send mail from form - InfoPath Dev
in

InfoPath Dev

Send mail from form

Last post 01-19-2006 10:41 AM by Matt Faus. 16 replies.
Page 1 of 2 (17 items) 1 2 Next >
Sort Posts: Previous Next
  • 01-10-2006 03:17 AM

    • Pich
    • Not Ranked
    • Joined on 01-10-2006
    • France
    • Posts 10

    Send mail from form

    Hi all,

    I creat a form linked to an access database.
    I want to be able sending mail from my form by entering an email and choosing a template.
    Is it possible?

    Thx for your help !

    BR,

    Pich
  • 01-10-2006 06:34 AM In reply to

    • uma
    • Top 500 Contributor
    • Joined on 12-23-2005
    • Posts 35
    Hi Pich,
    What do you mean by choosing a template?
    Is it your filled form?
    Anyway here are the steps to send form by email:
    1. Go to tools->data connections->submit data->as an email.
    2. Give the mail id address manually or select it from the “fx” button if it is one field value in your form in To/CC/BCC fields.
    3. Give the subject and attachment name if u want to send your form as attachment and complete the process of creating email data connection.
    4. Add a button to your form and add a rule to send an email using email data connection.


    Uma
    InfoPath Dev India
  • 01-10-2006 08:03 AM In reply to

    • Pich
    • Not Ranked
    • Joined on 01-10-2006
    • France
    • Posts 10
    Thank you for your answer !

    By template I mean a preformated email.
    So, I want to send this email from the form, and not send the form by email.
    The emails I want to send are about other data.

    i just want to create a button wich permit me to open a new mail when i click on it?

    Is it possible?

    BR,

    Pich
    ** so sorry for my english ""
  • 01-10-2006 09:34 AM In reply to

    Welcome to the forums, Pich and uma!

    Check out these threads and I think you will find an answer:

    http://infopathdev.com/forums/topic.asp?TOPIC_ID=1006
    http://infopathdev.com/forums/topic.asp?TOPIC_ID=621

    ---------------
    Matt Faus
    InfoPath Dev Texas
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 01-10-2006 09:43 AM In reply to

    • Pich
    • Not Ranked
    • Joined on 01-10-2006
    • France
    • Posts 10
    Thx a lot, it can help me !

    The problem is I dont know how to use this code... xD
    I don't have any knowledge in programmation; i'm learning but it's diffficult...

    Can u help using this code, just say me whish word are important in the code, wish i have to change and where i have to writte the script in the code page of the button :

    //Get the email adapter
    EmailAdapter oEmail = (EmailAdapter)thisXDocument.DataAdapters["Email"];

    //Set the to address
    oEmail.To = "abc#xyz.com";
    //In the above statement you can get the emailId from any one of the field that is in your form/Dataconnections.

    //Submit the email
    oEmail.Submit();


    Thx for all...

    BR

    Pich
  • 01-10-2006 12:12 PM In reply to

    To use this code, you will first have to add E-mail as a Submitting Data Source.

    1) In Design mode, choose Data Connections from the Tools Menu and then click Add.
    2) Select Submit Data, and then click Next.
    3) Select as an e-mail message, and then click Next.
    4) Delete all text in all textboxes on the window (you will be adding all of this content back in later using code). Click Next.
    5) On the next window enter a name into the textbox. Remember what you name it. Click Finish.

    Edit the following line in your code:

    //Get the email adapter
    EmailAdapter oEmail = (EmailAdapter)thisXDocument.DataAdapters["THE NAME YOU TYPED IN STEP FIVE"];


    Also, you might play around with the window box in step 4 so that you don't have to add everything back using code.

    Hope this helps, let us know if you have any more problems!

    PS - "whish" and "wish" should be "which" ("wish" has a very different meaning). Other than that your english is very good!

    ---------------
    Matt Faus
    InfoPath Dev Texas
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 01-16-2006 01:49 AM In reply to

    • Pich
    • Not Ranked
    • Joined on 01-10-2006
    • France
    • Posts 10
    Thank you,

    I begin to understand the "meaning" of this code, and the description you made of the different steps was very clear for me.

    Just one more question about it, i don't know where I've to copy this code when I'm editing the button's code.
    There is some place where I can write code as :
    - CTRL136_7::OnClick(eventObj)
    - XDocument::OnLoad(eventObj)
    - CTRL211_7::OnClick(eventObj)
    - XDocument::OnSaveRequest(eventObj)
    - XDocument::OnSign(eventObj)
    and 5 more "On sign" titles, can you help me on the meaning of the different part of the code, and how I can use them.

    Thank you again for your help,

    BR

    Pich
  • 01-16-2006 06:07 AM In reply to

    • Pich
    • Not Ranked
    • Joined on 01-10-2006
    • France
    • Posts 10
    Ok, I resolved the last problem!

    The different titles are the names of the buttons.

    One more precision, I don't know how to link the field in which i entered the email adresses.

    Indeed, I want to send email to all adresses entered in the form.
    In : oEmail.To = "mail adress" I don't know how set the field reference, the code needs a valid adress.
    More Over, I need help about setting the email body. For the moment I use : bjEmailAdapter.Intro = "intro" but i can't edit the email when submitting.

    BR

    Pich
  • 01-16-2006 09:04 AM In reply to

    Good job on resolving your problem! To get the e-mail addresses from your form you can use a line of code like this:

    thisXDocument.selectSingleNode( "XPath/To/Email/Node" ).text;

    After you get all the e-mail addresses you can concatentate them together in the oEmail.To line. Make sure to seperate with a ; .

    What's wrong with editing the body? Are you saying the code executes fine, but when you submit it it reverts back? Please post the whole source code.

    ---------------
    Matt Faus
    InfoPath Dev Texas
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 01-17-2006 07:08 AM In reply to

    • Pich
    • Not Ranked
    • Joined on 01-10-2006
    • France
    • Posts 10
    The problem is, when i use
    thisXDocument.selectSingleNode( "XPath/To/Email/Node" ).text;
    it returns me an error : 'thisXDocument' is undefined'

    What I want to do is send an e-mail to all the Email adresses saved in the DataBase linked to the form.

    I thank to use thisXDocument.selecNodes but I don't know how to use it...!

    This mail have to contain a picture as attachment.

    The code for the moment :

    function CTRL80_14::OnClick(eventObj)
    {

    //Get the email adapter
    var oEmail;
    oEmail = XDocument.DataAdapters("Mail");

    //email's body
    oEmail.Intro = "les offres de Janvier"

    //Set the to address
    oEmail.To = "[email protected]"

    //Submit the email
    oEmail.Submit();

    }



    BR Pich
  • 01-17-2006 06:27 PM In reply to

    Instead of using "thisXDocument" use "XDocument".

    thisXDocument - C# an VB.NET
    XDocument - JScript and VBScript

    Hope this helps!

    ---------------
    Matt Faus
    InfoPath Dev Texas
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 01-18-2006 09:07 AM In reply to

    • Pich
    • Not Ranked
    • Joined on 01-10-2006
    • France
    • Posts 10
    In this line :

    XDocument.selectSingleNode( "XPath/To/Email/Node" ).text;

    I don't understant the "XPath/To/Email/Node".
    I think it's about reference to the form but I don't know which reference I have o use.

    Can you help me on this point?

    BR

    Pich
  • 01-18-2006 09:21 AM In reply to

    XPath is used to traverse the DOM of your schema.

    If you made a blank new form and inserted one text field the XPath to get to that node would be:

    "/my:myFields/my:field1"

    Also, I'm sorry about the confusion, but instead of
    XDocument.selectSingleNode()
    it should be
    XDocument.DOM.selectSingleNode()
    I guess I forgot - my apologies!

    Here is further reference for XPath:http://www.w3schools.com/xpath/default.asp

    ---------------
    Matt Faus
    InfoPath Dev Texas
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 01-19-2006 02:14 AM In reply to

    • Pich
    • Not Ranked
    • Joined on 01-10-2006
    • France
    • Posts 10
    Ok, no problem :)

    My code looks-like that for the moment :

    oEmail.To = XDocument.DOM.selectSingleNode("myFields/dfs:dataFields/d:MainData/@Mail").text;

    But it returns me an error : Object Required
    I'm not sure of the references, what do you think about?
    Another question : Have I to write the code to find the node directly after oEmail.To ?
    And for finish, I don't know how to concatentate them. The SelectStringNode method give only the first node of the node-set.

    BR,
    Thank you for all.

    Pich

  • 01-19-2006 08:30 AM In reply to

    This probably has to do with your XPath, try adding the namespace on the first node:

    oEmail.To = XDocument.DOM.selectSingleNode("dfs:myFields/dfs:dataFields/d:MainData/@Mail").text;

    When you get the "Object required" error it is almost always an XPath error.

    I'm not sure what you mean by your second question, but to concatenate the e-mail addresses try something like this:

    var nodesAllEmails = XDocument.DOM.selectNodes( "dfs:myFields/dfs:dataFields/d:MainData/@Mail" );
    var sAllEmails = "";
    while( oneEmail = nodesAllEmails.nextNode() )
    {
    sAllEmails += oneEmail.text + "; ";
    }

    // Just for debugging
    XDocument.UI.Alert( sAllEmails );

    oEmail.To = sAllEmails;




    ---------------
    Matt Faus
    InfoPath Dev Texas
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
Page 1 of 2 (17 items) 1 2 Next >
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.