HTML in email - InfoPath Dev
in

InfoPath Dev

HTML in email

Last post 03-27-2007 04:47 AM by skrile. 10 replies.
Page 1 of 1 (11 items)
Sort Posts: Previous Next
  • 11-23-2005 10:10 PM

    • qwer
    • Top 500 Contributor
    • Joined on 10-04-2005
    • Posts 49

    HTML in email

    Hi all,

    Realising the fact that you can submit an email programmatically and declaring the intro content, can anyone tell me if there is a way to send an HTML email to the intro section?

    eg,

    set oEmail = XDocument.DataAdapters("Submit")
    oEmail.intro = "<html><head><title></title></head><body></body></html>"
  • 11-25-2005 06:05 AM In reply to

    Hi,

    I don't think you can! if with this way you cant I don't think that is possible!

    ++

    Thierry

    Every moment hesitated is a moment gone for life!!! Think about it
    Infopath 2007, Langage: C#2.0 (Modèle Objet 2003)
    merci de lire ceci
  • 11-28-2005 02:59 PM In reply to

    Sounds like a good Outlook question. My guess is that it is possible, but I haven't tried it.

    Patrick Halstead [InfoPath MVP]
    InfoPathDev
    Patrick Halstead
    Project Manager at Qdabra
  • 03-26-2007 08:02 AM In reply to

    • skrile
    • Top 500 Contributor
    • Joined on 08-17-2006
    • USA
    • Posts 29
    Man this one has been bothering me. Why in the world can't you put HTML in the body (Intro) programatically?

    (Author's Note: I had to put "[&]" where I mean "&" or else this forum will not render the message properly)

    Just for fun I've built a button with an OnClick event that triggers and email from a Data Connection:

    function CTRL596_5::OnClick(eventObj)
    {
    var emailrecip= XDocument.DOM.selectSingleNode("/my:myFields/my:emailrecip");
    {
    var objEmailAdapter = XDocument.DataAdapters("My Email Connection Name");
    objEmailAdapter.To = emailrecip.text;
    objEmailAdapter.CC = "";
    objEmailAdapter.BCC = "";
    objEmailAdapter.Intro = "Some special text"
    objEmailAdapter.Subject = "Test Email";
    objEmailAdapter.Submit();
    }
    }


    As noted before, putting HTML tags in the .Intro object just renders the literal tag in the email. Why this is bothersome to me is if I configure the Data Connection with Intro text and put carriage returns in the box within the wizard dialog, those carriage returns are rendered properly in the email. So, I went digging into the .xsf file to see how the info was stored. Low and behold, my line with carriage returns looks like this:


    <xsf:intro value="This line is two above[&]#xA;[&]#xA;this "></xsf:intro>


    Hmmm. [&]#xA; forces a carriage return when this Intro is used. So, one would think you could do something similar in script, but alas, you may have guessed the following DOES NOT work (again, the literal values are put in the email intro).


    objEmailAdapter.Intro = "Some special text[&]#xA;This is the next line"


    Anyone see a way to get HTML (at least carriage returns!!!) in the Intro section of an Email Adapter object programmatically?
  • 03-26-2007 12:34 PM In reply to

    • skrile
    • Top 500 Contributor
    • Joined on 08-17-2006
    • USA
    • Posts 29
    OY, it's soooo silly. To get carriage returns (or new lines) in JScript use "\r\n"

    As in:


    objEmailAdapter.Intro = "Some special text.\r\n This is the next line"

  • 03-26-2007 11:20 PM In reply to

    May be this is also of interest for you guys
    http://www.infopathdev.com/forums/topic.asp?TOPIC_ID=4116
    Listen to Motörhead cos they play Rock'n Roll :)
  • 03-27-2007 04:07 AM In reply to

    • skrile
    • Top 500 Contributor
    • Joined on 08-17-2006
    • USA
    • Posts 29
    Hmmm... Can't seem to make the example over there work. I started a new InfoPath form and put one button on the page. I then put this code behind the button (onclick).



    function CTRL1_5::OnClick(eventObj)
    {

    MailMessage objMail = new MailMessage();
    objMail.BodyFormat = System.Web.Mail.MailFormat.Html;
    objMail.From = "[email protected]";
    objMail.To = "[email protected]";
    objMail.Subject = "Test Subject";
    objMail.Body = "<b>FROM:</b>" + "<font color=red>" + "Sample TEXT" + "</font>"

    }



    When I preview the form and click the button I get:

    quote:

    InfoPath cannot open the selected form because of an error in the form's code.
    The following error occurred:

    Expected ';'
    File:script.js
    Line:25
    MailMessage objMail = new MailMessage();






    Any idea what is happening? And what is supposed to happen? Does this launch an Outlook email form?
  • 03-27-2007 04:10 AM In reply to

    It just gives you the freedom to create your own eMail body including html tags for formating.

    You need to change MailMessage objMail = .....
    to var objMail = new MailMessage();

    Like this you should get rid of the error.
    Listen to Motörhead cos they play Rock'n Roll :)
  • 03-27-2007 04:13 AM In reply to

    • skrile
    • Top 500 Contributor
    • Joined on 08-17-2006
    • USA
    • Posts 29
    Yeah, I tried that,



    function CTRL1_5::OnClick(eventObj)
    {

    var objMail = new MailMessage();
    objMail.BodyFormat = System.Web.Mail.MailFormat.Html;
    objMail.From = "[email protected]";
    objMail.To = "[email protected]";
    objMail.Subject = "Test Subject";
    objMail.Body = "<b>FROM:</b>" + "<font color=red>" + "Sample TEXT"

    }


    but when I click the button, now I get:

    quote:

    A run-time error has occurred....


    'MailMessage' is undefined
    File:script.js
    Line 25

  • 03-27-2007 04:19 AM In reply to

    Oh sorry I think this will only work with managed code and not with scripting. So you had to use the InfoPath toolkit for visual studio.
    Listen to Motörhead cos they play Rock'n Roll :)
  • 03-27-2007 04:47 AM In reply to

    • skrile
    • Top 500 Contributor
    • Joined on 08-17-2006
    • USA
    • Posts 29
    When I try to download this toolkit I get an error and it stops. I have InfoPath 2003 sp2 and Visual Studio 2005 installed on my machine. The error says I need InfoPath 2003 sp1 and Visual Studio 2003 installed. Am I just thick, or am I missing something important.

    http://www.microsoft.com/downloads/details.aspx?FamilyId=7E9EBC57-E115-4CAC-9986-A712E22879BB&displaylang=en)
Page 1 of 1 (11 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.