tags:

views:

214

answers:

5

Hi,

I'm sending a message from my ASP.net page to an email account, the message is sent properly and is viewable in Thunderbird or any other email client I use.

But I can not view the message text in my Windows Mobile 6.1 (BlackJacK II) device, I've played around with setting

    msg.BodyEncoding = System.Text.Encoding.Unicode;

or

    msg.BodyEncoding = System.Text.Encoding.UTF8;

or even

    msg.BodyEncoding = System.Text.Encoding.ASCII;

but none of these work and message body is simply not visible on the device.

the code to send the message is below

Where Body is an ASP.net TextBox control

 try
  {
    MailMessage msg = new MailMessage("[email protected]", "[email protected]");
    msg.Subject = "[TestProduct - TestPage.aspx]";
    msg.Body = Body.Text;
    msg.IsBodyHtml = true;
    SmtpClient sc = new SmtpClient("localhost");
    sc.Send(msg);
    txtMsg.Text = "Thank you for contacting TestCompany Inc someone will contact you promptly.";
  }
  catch
  {
    txtMsg.Text = "Unable to send your message at this time, Please try again later. Sorry for inconvineance.";
  }

When the IsBodyHtml = false and I do not set the Encoding these are the headers that I receive

From - Tue Jun 09 11:48:23 2009 Received: from chronos ([127.0.0.1]) by chronos.lunarpages.com with MailEnable ESMTP; Tue, 09 Jun 2009 11:45:09 -0700 MIME-Version: 1.0 From: Removed To: Removed Date: 9 Jun 2009 11:45:09 -0700 Subject: [TestProduct - TestPage.aspx] Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Return-Path:

test this message

and still I'm unable to see it in device.

A: 

Check to make sure the blackjack is set to receive HTML emails.

Jonathan
My device is set to receive HTML messages
AppDeveloper
A: 

I feel its the issue with your Mobile device. Did you try another device? Which browser are you using? Check your browser settings.

Shoban
I'm using the default outlook client to receive messages, is that what you meant?
AppDeveloper
If you are using outlook then choose the account and select "Doanload size settings" and make sure Message Format is selected as HTML.
Shoban
A: 

The mail client on the BlackJack probably cannot display HTML messages. Most email programs generate plain-text versions of the messages that they send. However, System.Net.Mail.SmtpClient does not do this automatically.

You can create an AlternateView object with a plain text version of the message by like this

string plainTextVersion = //... 
msg.AlternateViews.Add(AlternateView.CreateFromString(plainTextVersion, null, "text/plain");
msg.AlternateViews.Add(AlternateView.CreateFromString(Body.Text, null, "text/html");

EDIT: If the device can display HTML messages, this won't solve the problem.

SLaks
I tried this and it still doesn't work msg.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(Body.Text, null, "text/plain"));
AppDeveloper
A: 

Can you view the raw message on the mobile device? If so, I'd post it for some of the experts here. it would help greatly to see what's MIME parts the device attempting to render.

Roma
any hints on how it can be done?
AppDeveloper
+1  A: 

Just as a test, I'd try:

  • don't set IsBodyHtml at all
  • set Subject to "foo" (that literal string)
  • set Body to "bar" (that literal string)

that should give the simplest mail - if it works, change one thing at a time until it breaks :)

James Manning