Comments (16)
Can you give an example of the characters that are not being correctly displayed please?
What are you seeing instead?
from postal.
I use characters like é and è (french characters) , and i see é and è in the mail .
from postal.
i see "& # 2 3 3 ; " and "& # 2 3 2 ; " in the mail
from postal.
Are you creating plain text or HTML emails?
from postal.
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.
I will try, i keep you updated, thanks again
from postal.
It works, but is it possible to do this with a plain text email?
from postal.
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.
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.
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.
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.
my view page :
To: [email protected]
From: [email protected]
Subject: Important Message
Hello,
Message: @ViewBag.Message
Cordialement,
Démo
from postal.
Ah I see!
Try:
@Html.Raw(ViewBag.Message)
By default @somevar will HTML encode the string.
from postal.
It works !!!!
thanks again for your help
from postal.
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.
@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)
- Add support on other html attributes except alt in @Html.EmbedImage() HOT 2
- How to add external link with params? HOT 2
- Is this project still being supported? HOT 3
- How to identify if the email is sent or not HOT 4
- Html Helpers not working from console application HOT 4
- Postal MVC5 project references MVC 5.1.0.0 instead of 5.1.2 as the requirements state HOT 7
- Postal w/o MVC NuGet package?
- How to provide smtp settings runtime(not in web or app config)
- With Framework 4.6.2 it give error Attempted to access an element as a type incompatible with the array HOT 6
- Previewing emails with addresses with names HOT 4
- Install-Package : Input string was not in a correct format. HOT 6
- Continuation of Postal HOT 26
- enable sasl authentification HOT 7
- System.ArgumentNullException with .NET 4.5.2 WebApi HOT 9
- Sample For Postal.AspnetCore? HOT 3
- The parameter 'addresses' cannot be an empty string. HOT 1
- Layouts Stopped Working
- MVC4 throws exception when using autofac and MVC async controller actions HOT 3
- How to use Postal with Unity IoC Container MVC 5?
- Subject encoding HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from postal.