Giter Site home page Giter Site logo

Comments (7)

DWalkit avatar DWalkit commented on June 23, 2024 1

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.

andrewdavey avatar andrewdavey commented on June 23, 2024

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.

jfrank14 avatar jfrank14 commented on June 23, 2024

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.

petersondrew avatar petersondrew commented on June 23, 2024

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.

andrewdavey avatar andrewdavey commented on June 23, 2024

I recommend taking a look here:

void AssignCommonHeaders(MailMessage message, Email email)

It should be possible to add some extra guards for empty email addresses.

from postal.

jfrank14 avatar jfrank14 commented on June 23, 2024

Thanks. I will check it out.

On 8/26/2014 9:19 AM, Andrew Davey wrote:

I recommend taking a look here:

void AssignCommonHeaders(MailMessage message, Email email)

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.

petrosmm avatar petrosmm commented on June 23, 2024

@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)

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.