System.Web.Mail.MailMessage Headers.Add - Include vbCrLf

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • travispennington@yahoo.com

    System.Web.Mail.MailMessage Headers.Add - Include vbCrLf

    To anyone that can assist me: I deeply appreciate your help!!

    I am developing an application with an outside vendor. The vendor has
    a very odd requirement. They need custom X-Headers added to an email
    received by their system. That's not the odd part. The oddity is
    they want to have a single X-Header containing multiple keys and
    values that are delimited by a carriage return, line feed and tab.

    The vendor claims other customers have successfully met this
    requirement using Lotus Notes.

    Here's a snippet of code that attempts this requirement:
    Dim objMail As New System.Web.Mail .MailMessage
    objMail.To = strToAddress
    objMail.From = strFromAddress
    objMail.Subject = "test"
    System.Web.Mail .SmtpMail.SmtpS erver = "smtp_svr_1 "
    objMail.Headers .Add("X-Custom-Header", "key1: value1" & vbCrLf & vbTab
    & "key2: value2")

    When the email is received, this is where I fail the requirement. My
    header looks like this:
    X-Custom-Header: key1: value1 key2: value2

    The vendor says that my header should look like this:
    X-Custom-Header: key1: value1
    key2: value2

    In other words, they say the vbCrLf should wrap the text inside the
    header to a new line and then tab once. Although I have attempted
    numerous ways to insert the carriage return line feed, it always
    renders on a single line in the header. I've also tried using
    Environment.New Line() with no success.

    Is this even possible? My gut tells me no, but I'm hoping someone out
    there will be able to say "yes it's possible" and show me how.

    Thank you kindly for your time,
    Travis

  • Alexey Smirnov

    #2
    Re: System.Web.Mail .MailMessage Headers.Add - Include vbCrLf

    On Oct 25, 5:28 pm, travispenning.. .@yahoo.com wrote:
    To anyone that can assist me: I deeply appreciate your help!!
    >
    I am developing an application with an outside vendor. The vendor has
    a very odd requirement. They need custom X-Headers added to an email
    received by their system. That's not the odd part. The oddity is
    they want to have a single X-Header containing multiple keys and
    values that are delimited by a carriage return, line feed and tab.
    >
    The vendor claims other customers have successfully met this
    requirement using Lotus Notes.
    >
    Here's a snippet of code that attempts this requirement:
    Dim objMail As New System.Web.Mail .MailMessage
    objMail.To = strToAddress
    objMail.From = strFromAddress
    objMail.Subject = "test"
    System.Web.Mail .SmtpMail.SmtpS erver = "smtp_svr_1 "
    objMail.Headers .Add("X-Custom-Header", "key1: value1" & vbCrLf & vbTab
    & "key2: value2")
    >
    When the email is received, this is where I fail the requirement. My
    header looks like this:
    X-Custom-Header: key1: value1 key2: value2
    >
    The vendor says that my header should look like this:
    X-Custom-Header: key1: value1
    key2: value2
    >
    In other words, they say the vbCrLf should wrap the text inside the
    header to a new line and then tab once. Although I have attempted
    numerous ways to insert the carriage return line feed, it always
    renders on a single line in the header. I've also tried using
    Environment.New Line() with no success.
    >
    Is this even possible? My gut tells me no, but I'm hoping someone out
    there will be able to say "yes it's possible" and show me how.
    >
    Thank you kindly for your time,
    Travis
    try to add "\r\n" into line: "key1: value1\r\nkey2: value2"

    Comment

    • travispennington@yahoo.com

      #3
      Re: System.Web.Mail .MailMessage Headers.Add - Include vbCrLf

      Alexey,

      Thanks for trying to help. Unfortunately, the \r\n ends up being part
      of the same line and actually displays as part of a string. It looks
      like:
      "key1: value1\r\nkey2: value2"

      Any other thoughts?

      Comment

      • Bill Ross

        #4
        Re: System.Web.Mail .MailMessage Headers.Add - Include vbCrLf

        Just a wild guess..

        Would this work?:

        objMail.Headers .Add("X-Custom-Header", "key1: value1" & vbCrLf )
        objMail.Headers .Add("", "vbTab & "key2: value2")

        --
        Bill Ross

        Bible Shockers! A collection of disturbing observations of and about the
        Bible.


        <travispenningt on@yahoo.comwro te in message
        news:1193326134 .649535.22320@o 3g2000hsb.googl egroups.com...
        To anyone that can assist me: I deeply appreciate your help!!
        >
        I am developing an application with an outside vendor. The vendor has
        a very odd requirement. They need custom X-Headers added to an email
        received by their system. That's not the odd part. The oddity is
        they want to have a single X-Header containing multiple keys and
        values that are delimited by a carriage return, line feed and tab.
        >
        The vendor claims other customers have successfully met this
        requirement using Lotus Notes.
        >
        Here's a snippet of code that attempts this requirement:
        Dim objMail As New System.Web.Mail .MailMessage
        objMail.To = strToAddress
        objMail.From = strFromAddress
        objMail.Subject = "test"
        System.Web.Mail .SmtpMail.SmtpS erver = "smtp_svr_1 "
        objMail.Headers .Add("X-Custom-Header", "key1: value1" & vbCrLf & vbTab
        & "key2: value2")
        >
        When the email is received, this is where I fail the requirement. My
        header looks like this:
        X-Custom-Header: key1: value1 key2: value2
        >
        The vendor says that my header should look like this:
        X-Custom-Header: key1: value1
        key2: value2
        >
        In other words, they say the vbCrLf should wrap the text inside the
        header to a new line and then tab once. Although I have attempted
        numerous ways to insert the carriage return line feed, it always
        renders on a single line in the header. I've also tried using
        Environment.New Line() with no success.
        >
        Is this even possible? My gut tells me no, but I'm hoping someone out
        there will be able to say "yes it's possible" and show me how.
        >
        Thank you kindly for your time,
        Travis
        >

        Comment

        • travispennington@yahoo.com

          #5
          Re: System.Web.Mail .MailMessage Headers.Add - Include vbCrLf

          Bill, thanks for the attempt. There's a problem with that approach
          when I have more than 2 value key pairs. The header's key name has
          to be unique. For example, I can't have 2 of these:
          objMail.Headers .Add("", bla bla)
          The header key has be unique and their application is looking for a
          tab on the new line too.

          Comment

          • Alexey Smirnov

            #6
            Re: System.Web.Mail .MailMessage Headers.Add - Include vbCrLf

            On Oct 25, 8:29 pm, travispenning.. .@yahoo.com wrote:
            Alexey,
            >
            Thanks for trying to help. Unfortunately, the \r\n ends up being part
            of the same line and actually displays as part of a string. It looks
            like:
            "key1: value1\r\nkey2: value2"
            >
            Any other thoughts?
            I read that this works with some clients like Eudora, but I see that
            this is not the case with Outlook, or Gmail... How did you test it?
            Have you ever saw the line breaks from a Lotus Notes message?

            Comment

            • travispennington@yahoo.com

              #7
              Re: System.Web.Mail .MailMessage Headers.Add - Include vbCrLf

              I have been sending my test messages to a SmarterTools web based email
              account. I'm not viewing the header with a PC based email client.
              The vendor sent me a message generated from their system (Lotus Notes)
              to my same SmarterTools web email....and it's header had the line
              breaks displaying the way they want it. They even sent me a snippet
              of code demonstrating how they accomplish it in Lotus Notes, but it's
              the same thing I'm doing....they'r e just inserting vbCrLf into a
              header. Of course, the creation/attachment of the header is slightly
              different for Lotus, but everything else is the same.

              Comment

              • Bob

                #8
                Re: System.Web.Mail .MailMessage Headers.Add - Include vbCrLf

                I am not sure if you can do it or not with System.Web.Mail but this is
                deffintly a bug on the vendors side.

                X-Custom-Header: key1: value1 key2: value2

                is equivelent to

                X-Custom-Header: key1: value1
                key2: value2

                The line break (a.ka. folding) is a layer of RFC822 which is a way to get
                around line length limitations. They are misusing the RFC because their
                parsing developer(s) are to lazy to write a better parser.

                If you can't do it, and the vendor is not going to budge you may want to
                give the below component a try. I belive the headers are added untouched.


                They should have copied the Received header symantics and use a semi-colon
                instead.

                i.e.

                X-Custom-Header: Key1:Value;Key2 :Value2

                or just the below line where key is implicit.

                X-Custom-Header: Value1;Value2

                <travispenningt on@yahoo.comwro te in message
                news:1193326134 .649535.22320@o 3g2000hsb.googl egroups.com...
                To anyone that can assist me: I deeply appreciate your help!!
                >
                I am developing an application with an outside vendor. The vendor has
                a very odd requirement. They need custom X-Headers added to an email
                received by their system. That's not the odd part. The oddity is
                they want to have a single X-Header containing multiple keys and
                values that are delimited by a carriage return, line feed and tab.
                >
                The vendor claims other customers have successfully met this
                requirement using Lotus Notes.
                >
                Here's a snippet of code that attempts this requirement:
                Dim objMail As New System.Web.Mail .MailMessage
                objMail.To = strToAddress
                objMail.From = strFromAddress
                objMail.Subject = "test"
                System.Web.Mail .SmtpMail.SmtpS erver = "smtp_svr_1 "
                objMail.Headers .Add("X-Custom-Header", "key1: value1" & vbCrLf & vbTab
                & "key2: value2")
                >
                When the email is received, this is where I fail the requirement. My
                header looks like this:
                X-Custom-Header: key1: value1 key2: value2
                >
                The vendor says that my header should look like this:
                X-Custom-Header: key1: value1
                key2: value2
                >
                In other words, they say the vbCrLf should wrap the text inside the
                header to a new line and then tab once. Although I have attempted
                numerous ways to insert the carriage return line feed, it always
                renders on a single line in the header. I've also tried using
                Environment.New Line() with no success.
                >
                Is this even possible? My gut tells me no, but I'm hoping someone out
                there will be able to say "yes it's possible" and show me how.
                >
                Thank you kindly for your time,
                Travis
                >

                Comment

                • travispennington@yahoo.com

                  #9
                  Re: System.Web.Mail .MailMessage Headers.Add - Include vbCrLf

                  Bob, thanks for the referral on freesmtp.net. I'll check that out.
                  I agree about the RFC too. I haven't personally read the RFC myself,
                  but monkeying around with the formatting (appearance) didn't set well
                  with me either.

                  Comment

                  Working...