Hi all - thanks in advance. I'm generating emails that contain XML contentusing the following bit of code: MailMessage email = new MailMessage(SENDER_EMAIL, RECIPIENT_EMAIL, SUBJECT, sMessageBody); email.Headers.Remove("Content-Transfer-Encoding"); email.Headers.Add("Content-Transfer-Encoding", "7bit"); this._client = new SmtpClient(SMTP_SERVER, 25); this._client.Credentials = new NetworkCredential(CRED_ID, CRED_LOGIN); this._client.Timeout = TIMEOUT; this._client.Send(email); I added the Header remove and add code to try and prevent the problem I'm seeing where the emailheaders are alwyas automatically set to the following: content-type: text/plain; charset=us-ascii content-transfer-encoding: quoted-printable I am trying to get them to read: content-type: text/plain; charset=us-ascii content-transfer-encoding: 7bit ...because the example XML email I have has those headers. However, the code that I provided above set the email headers to: content-transfer-encoding: 7bit mime-version: 1.0 from: .... to: .... date: ... subject: ... content-type: text/plain; charset=us-ascii content-transfer-encoding: quoted-printable There are 2 sets of content-transfer-encoding headers. Now, the only reasons I am trying so hard to configure the headers is 1) the example I am following looks that way and 2) the original email I am sending out does not seem to be interpreting new lines correctly (note the =0A where there would otherwise be a new line): <?ADF VERSION "1.0"?>=0A=0A<adf>=0A<prospect>=0A<requestdate>2006-12-13T13:43:32-06:00</requestdate>=0A ... I am appending '\n' characters as I build the XML using a C# StringBuilder. I have tried many variations of my own headers, so I am beginnig to believe that this is somethign that DASP's smtp server adds to the emails automatically...how do I fix this problem?
you won't able to remove or add that header via the 'Headers' collection because it is pulled from within the object itself. You will have to modify this through the 'TransferEncoding' property. The TransferEncoding property is available for Attachment and AlternateView within the MailMessage object. Try this to see if you get the desired result... SmtpClient _client = new SmtpClient(); MailMessage email = new MailMessage(SENDER_EMAIL, RECIPIENT_EMAIL); email.Subject = SUBJECT; AlternateView plainView = AlternateView.CreateAlternateViewFromString(sMessageBody, Nothing, "text/plain"); plainView.TransferEncoding = System.Net.Mime.TransferEncoding.SevenBit; email.AlternateViews.Add(plainView); this._client = new SmtpClient(SMTP_SERVER, 25); this._client.Credentials = new NetworkCredential(CRED_ID, CRED_LOGIN); this._client.Timeout = TIMEOUT; this._client.Send(email); btw, I haven't tested this myself... so I don't actually know if it works. Joel Thoms DiscountASP.NET http://www.DiscountASP.NET
You might also want to participate or follow this thread... http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=98783&SiteID=1 Joel Thoms DiscountASP.NET http://www.DiscountASP.NET
The suggestions above worked out quite well. The only remaining issue is this: content-transfer-encoding: sevenbit Does it matter that this isn't 7bit?
http://www.rfc-archive.org/getrfc.php?rfc=2045 the RFC (2045 section 6.1)is clearly showing the only acceptible values for the Content-Transfer-Encodingfield are"7bit" / "8bit" / "binary" / "quoted-printable" / "base64". If the CDO object is outputting "sevenbit" instead of "7bit", then this is a bug and should be submitted to microsoft. You might be stuck using a 3rd party control. I also noticed you could set 'Unknown' with System.Net.Mime.TransferEncoding.Unknown. Maybe this will unset the header, allowing you to add the header manually? again... i haven't run or tested any of this code... Joel Thoms DiscountASP.NET http://www.DiscountASP.NET