Giter Site home page Giter Site logo

use of special character about postal HOT 16 CLOSED

andrewdavey avatar andrewdavey commented on September 25, 2024
use of special character

from postal.

Comments (16)

andrewdavey avatar andrewdavey commented on September 25, 2024

Can you give an example of the characters that are not being correctly displayed please?
What are you seeing instead?

from postal.

mcaradec avatar mcaradec commented on September 25, 2024

I use characters like é and è (french characters) , and i see é and è in the mail .

from postal.

mcaradec avatar mcaradec commented on September 25, 2024

i see "& # 2 3 3 ; " and "& # 2 3 2 ; " in the mail

from postal.

andrewdavey avatar andrewdavey commented on September 25, 2024

Are you creating plain text or HTML emails?

from postal.

andrewdavey avatar andrewdavey commented on September 25, 2024

Ah, try changing the content type of your HTML email view to this:
Content-Type: text/html; charset=utf-8

i.e. specifying the charset

from postal.

mcaradec avatar mcaradec commented on September 25, 2024

I will try, i keep you updated, thanks again

from postal.

mcaradec avatar mcaradec commented on September 25, 2024

It works, but is it possible to do this with a plain text email?

from postal.

mcaradec avatar mcaradec commented on September 25, 2024

Hi, i tried to define a charset into a plain text email or encode the viewbag.Message but nothing works, do you have an idea about this ?

from postal.

andrewdavey avatar andrewdavey commented on September 25, 2024

Can you configure web.config to save emails to a directory and then take a look at the generated ".eml" file?
Paste the contents of the file into a comment here please. I can then see what headers are being generated and the encoding. Thanks.

from postal.

mcaradec avatar mcaradec commented on September 25, 2024

below the content of the file, the content inside the viewbag is not displayed properly. However if I put an "é" into the view , it displays well

X-Sender: [email protected]
X-Receiver: [email protected]
MIME-Version: 1.0
From: [email protected]
To: [email protected]
Date: 11 May 2011 15:24:06 +0200
Subject: Important Message
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: base64

DQpIZWxsbywNCg0KTWVzc2FnZTogJiMyMzM7dmFkZXINCg0KQ29yZGlhbGVtZW50
LA0KRMOpbW8NCg==

And the result in outlook :

Hello,
Message: & # 2 3 3 ; vader
Cordialement,
Démo

from postal.

andrewdavey avatar andrewdavey commented on September 25, 2024

Thanks. Can you paste in the view page as well? I'm trying to work out why it's generating an HTML entity. I don't see that happening at my end.

from postal.

mcaradec avatar mcaradec commented on September 25, 2024

my view page :

To: [email protected]
From: [email protected]
Subject: Important Message

Hello,

Message: @ViewBag.Message

Cordialement,
Démo

from postal.

andrewdavey avatar andrewdavey commented on September 25, 2024

Ah I see!
Try:
@Html.Raw(ViewBag.Message)

By default @somevar will HTML encode the string.

from postal.

mcaradec avatar mcaradec commented on September 25, 2024

It works !!!!
thanks again for your help

from postal.

MortenChristiansen avatar MortenChristiansen commented on September 25, 2024

Just a little tip to avoid this for all your email templates (it does require you to put your email templates outside the views folder with its own razor web.config, unless you want to disable html encoding in all your views). You can make all your email views inherit from a custom class that does not html-encode variables. Something like this:

public abstract class EmailTemplateView<TModel> : WebViewPage<TModel>
{
    public override void Write(object value)
    {
        WriteLiteral(value);
    }
}

Then change the view base-class in the razor web.config file in the email templates folder:

<pages pageBaseType="mynamespace.EmailTemplateView">

This will stop encoding of all your emails so be careful if you also have html emails. I don't know if there is a clean way to either have a different base class for html emails or to detect the format inside the custom view class.

from postal.

andrewdavey avatar andrewdavey commented on September 25, 2024

@clone1985 Thanks for the awesome tip!
There may be a way for Postal to tell the view it's rendering plain text and toggle the behaviour of Write accordingly.

from postal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.