Email currency problem

Last post 10-18-2008 10:02 PM by Antho71. 1 replies.

Sort Posts:

  • Email currency problem

    10-18-2008, 2:11 PM

    I am unable to solve a problem with the email sent from the showad.aspx page. The same problem occurs whether I am using the page on my local machine or on a remote webserver. The problem occurs when the user sends the ad to a friend. The body of the email displays correctly with the text as

     

    Ad: old car
    Category: Auto
    Price: £120.00

    The email gets sent alright but when it is received it looks like this:

     

    Ad: old car
    Category: Auto
    Price: £120.00

    The webconfig includes

    <system.web>

    <globalization fileEncoding="utf-8" requestEncoding="utf-8" responseEncoding="utf-8" culture="en-GB" uiCulture="en"/>

    </system.web>

    I have tested the email with outlook, outlook express, thunderbird, lotus notes and hotmail all with the same results.

    any ideas?

  • Re: Email currency problem

    10-18-2008, 10:02 PM
    • Member
      124 point Member
    • Antho71
    • Member since 01-20-2005, 12:00 PM
    • County Mayo, Republic of Ireland
    • Posts 29

    Hi,

    I have just attempted to send an email containing an '€' character using System.Net.Mail and all went well. I didn't have to specify a globalization setting in the web.config file either.

    Unfortunately, I was unable to download the ASP.NET started kit (http://www.asp.net/Downloads/starter-kits/), as the link is currently down. This is the code I usually use to send mail:

    using System;
    using System.Collections.Generic;
    using System.Web;
    using System.Net.Mail;
    public class Emailer
    {
    public static bool Send(string fromAddress, string toAddress, string subject, string body, bool sendAsHTML)
    {
    try{
    //Build message...
    MailMessage msg = new MailMessage(fromAddress, toAddress, HttpUtility.HtmlEncode(subject), body);
    //Send as HTML?
    if (sendAsHTML)
    msg.IsBodyHtml = true;
    else
    msg.IsBodyHtml = false;

    //Send message...
    SmtpClient mailObj = new SmtpClient();
    mailObj.Send(msg);
    return true;
    }
    catch
    {
    return false;
    }

    }
    }

    An example of a call to the above might be:

    uxEmailSendResult.Text = Emailer.Send("\"Joe Blogs\" <joeblogs@yourdomain.com>",
    "joeblogs@receipentdomain.com"
    ,
    "Test Subject", "Body text goes here... €£$123.00", true).ToString();

    I used an ASP Label control here just to display the result of the call to 'Emailer.Send(...)'. Note the format of the 'from' address. You could also have used 'ConfigurationManager.AppSettings', which reads 'name/value' pairs from the web.config file instead of hard coding, as I did with the from address in the above call to 'Emailer.Send(...)'.


    Anyway, I wish I could help more.


    Best of luck!
    Anthony Walsh

    #Please# remember to click "Mark as Answer" on the post that helps you. This can be beneficial to other community members reading the thread.
Page 1 of 1 (2 items)