Pass the name into HTM file

Discussion in 'ASP .Net' started by JoeP, Mar 6, 2007.

  1. JoeP

    JoeP Guest

    Hi All,



    I have an HTML which I load as string and send it via MailMessage class.
    oMailMessage.Body = cHTMLString



    Before it is sent as e-mail I need to pass the HTM file the user

    First and Last in the first line.



    It is a form where the user enters his/her details and then it is

    e-mailed the user with the HTM file within the e-mail's body.



    It would start like:



    Hi Steve Smith,



    How can I embed the First and Last name of the user into the htm file?



    Thanks,



    Joe
     
    JoeP, Mar 6, 2007
    #1
    1. Advertising

  2. JoeP

    Mark Rae Guest

    "JoeP" <> wrote in message
    news:...

    > I have an HTML which I load as string and send it via MailMessage class.
    > oMailMessage.Body = cHTMLString
    >
    > Before it is sent as e-mail I need to pass the HTM file the user
    > First and Last in the first line.
    >
    > It is a form where the user enters his/her details and then it is
    > e-mailed the user with the HTM file within the e-mail's body.
    >
    > It would start like:
    >
    > Hi Steve Smith,
    >
    > How can I embed the First and Last name of the user into the htm file?


    oMailMessage.Body = "Hi " + txtFirstName.Text + " " + txtLastName.Text +
    ",\r\n\r\n";
    oMailMessage.Body += cHTMLString;
     
    Mark Rae, Mar 6, 2007
    #2
    1. Advertising

  3. JoeP

    JoeP Guest

    Hi Mark,

    Thanks for your reply. But how do I keep the Verdana font of that embeded
    string?
    Also the semi column was a problem and got an err which is: Character is not
    valid

    oMailMessage.Body = "Hi " + txtFirstName.Text + " " + txtLastName.Text +
    ",\r\n\r\n";
    oMailMessage.Body += cHTMLString;

    Thanks,

    Joe
     
    JoeP, Mar 6, 2007
    #3
  4. JoeP

    Mark Rae Guest

    "JoeP" <> wrote in message
    news:OjyJY8$...

    > Thanks for your reply. But how do I keep the Verdana font of that embeded
    > string?


    oMailMessage.IsBodyHtml = true;

    > Also the semi column was a problem and got an err which is: Character is
    > not valid


    Ah - I assumed you were using C#...

    If you're using VB.NET, you'll (probably) need to do something like:

    oMailMessage.Body = "Hi " & txtFirstName.Text & " " & txtLastName.Text &
    vbCrLf & vbCrLf
    oMailMessage.Body = oMailMessage.Body & cHTMLString

    oMailMessage.IsBodyHtml = True
     
    Mark Rae, Mar 6, 2007
    #4
  5. JoeP

    JoeP Guest

    Hi Mark,

    Your idea works as well, but even though: oMailMessage.IsBodyHtml = True
    The fornt of the below is not the same any more:

    oMailMessage.Body = "Hi " & txtFirstName.Text & " " & txtLastName.Text &
    vbCrLf & vbCrLf

    What I did is: In the first line of the HTM file I did as follows:
    Hi {First Name} {Last Name},

    Then:
    cHTMLString = cHTMLString.Replace("{First Name}", txtFName.Text)

    cHTMLString = cHTMLString.Replace("{Last Name}", txtLName.Text)

    Thanks,

    Joe
     
    JoeP, Mar 6, 2007
    #5
  6. Hi,
    Actually solution was simple just add font tag in html
    like

    oMailMessage.Body = "Hi <font face=verdana size=10>" & txtFirstName.Text & "
    " & txtLastName.Text & "</font>"
    vbCrLf & vbCrLf
    oMailMessage.Body = oMailMessage.Body & cHTMLString

    oMailMessage.IsBodyHtml = True

    it will definately work

    cheers
    Chetan Chaphekar

    "JoeP" wrote:

    > Hi Mark,
    >
    > Your idea works as well, but even though: oMailMessage.IsBodyHtml = True
    > The fornt of the below is not the same any more:
    >
    > oMailMessage.Body = "Hi " & txtFirstName.Text & " " & txtLastName.Text &
    > vbCrLf & vbCrLf
    >
    > What I did is: In the first line of the HTM file I did as follows:
    > Hi {First Name} {Last Name},
    >
    > Then:
    > cHTMLString = cHTMLString.Replace("{First Name}", txtFName.Text)
    >
    > cHTMLString = cHTMLString.Replace("{Last Name}", txtLName.Text)
    >
    > Thanks,
    >
    > Joe
     
    =?Utf-8?B?Q2hldGFuIENoYXBoZWthcg==?=, Mar 7, 2007
    #6
  7. JoeP

    Mark Rae Guest

    "Chetan Chaphekar" <> wrote in
    message news:...

    > it will definately work


    As far as you are concerned, it will definitely work...

    However, you need to think quite carefully about sending HTML emails...

    Most modern mail software can be configured not only to strip out all HTML
    content, but also to reject emails with HTML content...

    Depending on how paranoid / security-conscious your recipients are, they
    might never even see your emails if you send them in HTML format...
     
    Mark Rae, Mar 7, 2007
    #7
  8. JoeP

    JoeP Guest

    Hi Mark,

    The problem is that I have some links in that HTM file. So I how can I
    provide those links without any HTM code. Otherwise the user will need to
    copy the URL into the Browser. Not that productive.

    Regards,

    Joe
     
    JoeP, Mar 7, 2007
    #8
  9. JoeP

    Mark Rae Guest

    "JoeP" <> wrote in message
    news:...

    > The problem is that I have some links in that HTM file. So I how can I
    > provide those links without any HTM code.


    You can't...

    > Otherwise the user will need to copy the URL into the Browser.


    That's true.

    > Not that productive.


    Even less productive if the email gets rejected by the user's mail client
    before the user even has a chance to see it...

    Your call...
     
    Mark Rae, Mar 7, 2007
    #9
  10. Hi Joep,

    What mark has said is right but also consider the percentage of receipient
    who has this kind of settings. almost all sites who send newsletter to the
    subscriber use HTML code in their email.

    cheers
    chetan chaphekar



    "JoeP" wrote:

    > Hi Mark,
    >
    > The problem is that I have some links in that HTM file. So I how can I
    > provide those links without any HTM code. Otherwise the user will need to
    > copy the URL into the Browser. Not that productive.
    >
    > Regards,
    >
    > Joe
    >
    >
    >
     
    =?Utf-8?B?Q2hldGFuIENoYXBoZWthcg==?=, Mar 8, 2007
    #10
  11. JoeP

    Mark Rae Guest

    "Chetan Chaphekar" <> wrote in
    message news:...

    > but also consider the percentage of receipient who has this kind of
    > settings.


    Increasing all the time...

    > almost all sites who send newsletter to the subscriber use HTML code in
    > their email.


    More and more now give their recipients the option of receiving such
    correspondence either in plain text or HTML...
     
    Mark Rae, Mar 8, 2007
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark Sandfox
    Replies:
    2
    Views:
    4,177
    Mark Sandfox
    Jun 24, 2004
  2. Ole Svensen
    Replies:
    2
    Views:
    361
    Hywel Jenkins
    Dec 17, 2003
  3. =?Utf-8?B?TWlrZQ==?=
    Replies:
    3
    Views:
    322
    David
    Apr 9, 2007
  4. Glenn
    Replies:
    6
    Views:
    112
    Glenn
    Jan 1, 2009
  5. Replies:
    6
    Views:
    181
    Dr.Ruud
    Feb 6, 2007
Loading...

Share This Page