473,785 Members | 2,824 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Oct 25 '07 #1
8 5191
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"

Oct 25 '07 #2
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?

Oct 25 '07 #3
Just a wild guess..

Would this work?:

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

--
Bill Ross
http://bibleshockers.com
Bible Shockers! A collection of disturbing observations of and about the
Bible.
<tr************ **@yahoo.comwro te in message
news:11******** *************@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
Oct 25 '07 #4
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.

Oct 25 '07 #5
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?

Oct 25 '07 #6
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.

Oct 25 '07 #7
Bob
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.
http://www.freesmtp.net

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

<tr************ **@yahoo.comwro te in message
news:11******** *************@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

Oct 25 '07 #8
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.

Oct 25 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
1671
by: Peter Afonin | last post by:
Hello, I created an e-mail form pretty much as described in this article: http://www.4guysfromrolla.com/webtech/080801-1.shtml. It works great, but I cannot figure out one thing: I need to insert a URL at the bottom of the message body. How would I do this? If I insert just HTML - it displays HTML. I tried Response.Write method, StringBuilder and HTMLTextWriter classes - no luck so far.
0
1271
by: gh0st54 | last post by:
Hi i'm looking for how to change the date of out going messages i tried this but it doesn't seems to work static public bool SendEmail(string To, string From, string Subject, string Body, System.Web.Mail.MailFormat Format) { bool bReturn = false;
0
1230
by: Dan___ | last post by:
How to send a mailmessage with a return receipt? I use the property Headers of the class MailMessage dim myMail as new MailMessage myMail.Headers.Add("Return-Receipt-To", <address@mail.com>) myMail.Headers.Add("Disposition-Notification-To", <address@mail.com>) The header "Disposition-Notification-To" run, not "Return-Receipt-To".
3
3499
by: chuckdfoster | last post by:
When using this bit of code, it sends two emails most of the time. Sometimes it doesn't send two, but most of the time it does. I put the system time (Now) in the Subject and each email has a different time by a minute or so. I also tried to count the number of emails it is sending by using the intEmail = intEmail + 1, but the number is always 1.Could anyone tell me why this is happening or give me advice on how to change it. Thanks...
1
1973
by: MickeBoy | last post by:
Hi all! I'm trying to send a HTML mail using the MailMessage class. Sending the message works fine, but there is something funny with the received message. I use the code below to generate and send a sample message. When I recieve it and open it in Outlook 2003 the style for my table cell is not applied. This is because the dot (.) before the class in the style tag has been removed!! If I insert another dot before class definition in the...
8
5474
by: marcmc | last post by:
Trying to send an eMail frommy vb.net App. Is there anybody out there that has successfully done this? I am having major problems and need a step by step guide into the world of system.web and IIS. The reading I have done(alot) has been pretty useless in helping me understand the various bits required. The error I get is: On a pc running win2k with IIS and Lotus Notes System.Runtime.InteropServices.SEHException: External component has...
1
3499
by: asnowfall | last post by:
I am creating MailMessage out of already existing email message. My existing message has few custom properties. I wan to add them to System.Net.Mail.MailMessage How to add custom properties? I was thinking adding custom properties to System.Net.Mail.MailMessage.Headers. but it's a READONLY property. System.Net.Mail.MailMessage has few header fields as properties (eg: FROM, TO, CC) and these are not sufficient.
0
1179
by: Kevin Hodgson | last post by:
I'm having a problem with System.Web.Mail.MailMessage losing linefeeds when creating an email. This is a VB.NET project. I use a stringbuilder to construct the MailMessage.Body and use vbCrLf or vbNewLine to format the message body. Double lines always seem to work (vbCrLf & vbCrLf or vbNewLine & vbNewLine) however single linefeeds (vbCrLf or vbNewLine) only work the first few lines in a message, and then they stop working, which...
4
2399
by: David C | last post by:
I would like to have an email go to 2 email addresses but when I try it by separating with semicolon or comma it fails. Can anyone help? below is my code (see ToAddress string). Thanks. David strUser = UtilClass.GetUserName(strUser) '!!! UPDATE THIS VALUE TO YOUR EMAIL ADDRESS Const ToAddress As String = "me@myemail.com" Const FromAddress As String = "me@myemail.com"
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10090
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9949
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8971
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5380
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.