Comments (7)
In case anyone else runs into this, an easy workaround (at least it works in MVC4) is to move the Bcc or CC to the bottom of your header, with a Razor @if, like so:
To: @ViewBag.To
From: @ViewBag.From
Subject: @ViewBag.Subject
Content-Type: text/html @if (@ViewBag.CC != null) {
CC: @ViewBag.CC
}
If I put the CC part on its own line it wouldn't always work. And I actually included the 'CC:' in the ViewBag.CC but added it above as I'd imagine it'd work that way, too! Obviously, in your controller code, you'll want to set email.CC = null if you have no addresses to add! And I have it all on one line, GitHub is formatting it for me! It may not work on more than one line!
from postal.
Please do fork the code and have a go at fixing this. I'd be very happy to accept a pull request. Thanks :)
from postal.
Why does it have to be at the end of the file? Wouldn't it work the same if it came right after the To: line?
from postal.
I took a slightly different approach since I use strongly-typed emails. I use a shared layout for my email templates with the following:
@model Models.EmailBase
To: @Model.To
From: [email protected]
Subject: @Model.Subject
Content-Type: text/html; charset=utf-8
@RenderSection("bcc", required: false)
Then in my email view:
@model Models.SomeEmaliWithBcc
@section bcc {BCC: @Model.Bcc}
That could also easily be extended to handle cases where Bcc is null or empty:
@model Models.SomeEmaliWithBcc
@if (!String.IsNullOrEmpty(Model.Bcc))
{
@section bcc {BCC: @Model.Bcc}
}
from postal.
I recommend taking a look here:
postal/src/Postal/EmailParser.cs
Line 55 in 409617d
It should be possible to add some extra guards for empty email addresses.
from postal.
Thanks. I will check it out.
On 8/26/2014 9:19 AM, Andrew Davey wrote:
I recommend taking a look here:
postal/src/Postal/EmailParser.cs
Line 55 in 409617d
It should be possible to add some extra guards for empty email addresses.
Reply to this email directly or view it on GitHub #38 (comment).
from postal.
@DWalkit wrote correctly in his analysis of the problem. However, does any such remedy exist for the 'Reply-To', it has a much different behaviour.
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 3
- 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 5
- 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 4
- Previewing emails with addresses with names HOT 3
- Install-Package : Input string was not in a correct format. HOT 5
- 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
- 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.