Send automatic mail without clicking send button - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Send automatic mail without clicking send button

Last post 12-11-2008 05:55 AM by Anuma. 12 replies.
Page 1 of 1 (13 items)
Sort Posts: Previous Next
  • 03-26-2007 10:24 PM

    • mrudula
    • Top 500 Contributor
    • Joined on 02-14-2007
    • India
    • Posts 31

    Send automatic mail without clicking send button

    Hi All,

    I searched a lot in forum before sending this query but didnt get any solution. I have written a code to send mail with infopath form attached to it with the help of Email adapter and submitting it. I am getting window asking send button and cancel button before sedning mail through the email data connection. I dont want to ask user this question, I want to send mail automatically.
    Code-

    //if email data connection is done in the infopath form
    EmailAdapter EmailAdptr = (EmailAdapter)myXDoc.DataAdapters["Email Submit"];
    EmailAdptr.Submit();

    Is it possible? and how? Could anybody help me out this?

    Regards,
    Mrudula
  • 03-26-2007 11:15 PM In reply to

    Re: Send automatic mail without clicking send button

    Hi, I would not use the EmailAdapter but MailEnvelope instead.
    Just search the from for it an i think you'll find a solution.
    Just write your own eMail sending without using the data connection, you can also attach the infopath form to that mail programatically.
    Listen to Motörhead cos they play Rock'n Roll :)
  • 03-27-2007 01:04 AM In reply to

    • mrudula
    • Top 500 Contributor
    • Joined on 02-14-2007
    • India
    • Posts 31

    Re: Send automatic mail without clicking send button

    Thanks for help.
    Ya, I have also tried with MailEnvelope but there also it asks to click send button which I dont want.
    Code-
    Infopath.MailEnvelope myEnvelope = apclass.ActiveWindow.MailEnvelope;
    myEnvelope.To = emailid;
    myEnvelope.Subject = "Test Mail";
    myEnvelope.Visible = true;

    This is the code that I tried.This also shows infopath form in the body of mail that I want.But it needs user interactionto send mail.
    Could you please tell me how to write own code to send mail with the help of MailEnvelope?

    Regards,
    Mrudula
  • 03-27-2007 01:26 AM In reply to

    Re: Send automatic mail without clicking send button

    Ah okay. Then I think you have no other choice but...

    Put a button to your form and select edit code to write your own code:

    First thing you need to do is use the thisXDocument.SaveAs() method to temporary save your infopath form to C:\temp on your local disc for example.

    After that you can use then the MailMessage object to achive what you want, you need to add the attachment of course. should be something similar to this:

    			MailMessage mes = new MailMessage();
    mes.From = "test@company.ca";
    mes.To = "test@company.ca";
    mes.Attachments.Add("C:\\temp\\yourForm.xml);


    Keep in mind using the SaveAs method requires your form to be set to full trust.

    Give it a try hope it'll work for you. Let me know if it helped.
    Listen to Motörhead cos they play Rock'n Roll :)
  • 03-27-2007 01:48 AM In reply to

    • mrudula
    • Top 500 Contributor
    • Joined on 02-14-2007
    • India
    • Posts 31

    Re: Send automatic mail without clicking send button

    Thanks for reply.

    The flow of my work is like this,
    When user clicks button on application, the already saved form should go through mail to the specific person. I can get emailids and all through code. I just want to send this Infoapth form in the body of mail and not as an attachment. As using EmailAdapter and MailEnvelope we can send form in the body of mail I want like that stucture of the mail body. So I tried it using both but it needs user interaction.
    Sending mail as you said through code only attach form to mail and it doesnt embed form in the body of mail.

    So can I do something similar to this? Please help me through this.

    Regards,
    Mrudula
  • 03-27-2007 02:35 AM In reply to

    Re: Send automatic mail without clicking send button

    Okay then the only other thing I could imagine how to do is to follow the idea julie-mids posted here.
    It's already a while ago when I red this but was able to find it again.

    http://www.infopathdev.com/forums/topic.asp?TOPIC_ID=1006&SearchTerms=slight

    have a look for this section:

    """Well I have cheated slightly but I've come up with a really nice way of sending the form as the email body and in the exact same form as it is on Infopath.
    I found the email code on one of the Customized forms with Inpopath (the Issue tracking one). I just deleted everything and copied my form onto it and it works beautifally!
    The email result is a perfect copy of the form inside the email body.. theres probably a hitch somewhere that I haven;t found yet!"""
    Listen to Motörhead cos they play Rock'n Roll :)
  • 03-27-2007 02:54 AM In reply to

    Re: Send automatic mail without clicking send button

    Won't work either, also requires you to click send.
    Hm this is a tricky one...
    Listen to Motörhead cos they play Rock'n Roll :)
  • 03-27-2007 03:32 AM In reply to

    • mrudula
    • Top 500 Contributor
    • Joined on 02-14-2007
    • India
    • Posts 31

    Re: Send automatic mail without clicking send button

    Thanks for reply.

    ya right,we cannot do like that. I have already tried that too.It too asks to click send button.

    Could we able to do it? is it possible to send mail without interraction with user? It should be,right? But I cannot find it right away.
    And I want it urgently, I serached alot. Please help me through.

    Regards,
    Mrudula
  • 03-27-2007 04:14 AM In reply to

    Re: Send automatic mail without clicking send button

    I wouldn't know now of any other way but to create your own eMail body.

    With this:
    MailMessage objMail = new MailMessage();
    objMail.BodyFormat = System.Web.Mail.MailFormat.Html;
    objMail.From = "from@address.ca";
    objMail.To = "to@address.ca";
    objMail.Subject = "Test Subject";
    objMail.Body = "<b>FROM:</b>" + "<font color=red>" + "Sample TEXT" + "</font>"


    you will be able to create your own custom eMail body using html tags for formattig. Like this then you can put all the required data into the mail body. Will cost you some time to write the code depending on how many values (coming from your controls) you wanna put into the mail body.

    That's really the last idea i have right now.
    May be someone else knows another solution.

    Good luck !
    Listen to Motörhead cos they play Rock'n Roll :)
  • 03-27-2007 04:23 AM In reply to

    • mrudula
    • Top 500 Contributor
    • Joined on 02-14-2007
    • India
    • Posts 31

    Re: Send automatic mail without clicking send button

    Thanks for your quick reply. And thanks for time you had spent on this.

    Ya that also I tried but I dont want to show the HTML view of the form I also want user to edit in some of the controls of form.

    It's so not happening. I searched a lot on this. It costs me a lot. What do I do? Somenody please help me out.

    Regards,
    Mrudula
  • 03-27-2007 07:53 PM In reply to

    Re: Send automatic mail without clicking send button

    I don't think it can be done.

    I spent a lot of time on this problem.

    In the end, I think it's because Infopath itself needs to send the email through an email application, so it uses whatever your default email app is. But it can't just send a message. It always requires a confirmation - which makes sense. Imagine emails being sent from an end user's email account without his/her knowledge. It's not very secure.

    If you find a solution, please post it. I'm sure there are dozens of Infopath programmers that would love to read about it.
  • 12-11-2008 05:31 AM In reply to

    Re: Send automatic mail without clicking send button

     I created a InfoPath which sends out an email and would like to have “Send” button with default index so that the forms gets submitted successfully.  Could you please guide me or direct me to the resource or KB which details on how to adjust the default index on email message popup in InfoPath form.

     

  • 12-11-2008 05:55 AM In reply to

    • Anuma
    • Top 25 Contributor
      Female
    • Joined on 07-20-2005
    • India
    • Posts 525

    Re: Send automatic mail without clicking send button

    Hi Akanksha,

    Welcome to the Forums. 

    Can you try these steps.

    1. Double click on button to open button properties dialog
    2. Select “Submit” in the Action dropdown.
    3. Select “Enable submit Commands and buttons’ option in the submitting Form dialog box.
    4. Select Email in the “Submit to” dropdown.
    5. Click on add button.
    6. Select “FX” button beside of the TO field.
    7. Select the field where you are getting the “To” value from. (Ex: if you are entering in the form, enter that field path; or if you are getting from any secondary data source, enter secondary data source path)
    8. Enter the Subject what you want.
    9. Click on next and click on finish.
    Anuma Chinthapalli /
    http://www.GGKTech.com
Page 1 of 1 (13 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.