smsohan / MvcMailer

A Mailer for ASP.Net MVC that forms the Email Body using MVC Views (Razor etc.) following Ruby on Rails ActionMailer style
MIT License
584 stars 178 forks source link

Problem embedding resource #30

Closed jonchai closed 12 years ago

jonchai commented 12 years ago

Without embedding resource, it I can send out emails just fine. However, if I were to try the following:

PopulateBody(mailMessage, viewName: "ResetPassword", linkedResources: resources);

I get error Could not find a part of the path. I have set "/Content/images/logo.png" as my path but it points to 'C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\10.0\Content\images\logo.png' instead. Any idea how I could get this going?

smsohan commented 12 years ago

Use server.MapPath or something similar to map the path relative to your bin.


Sent from my iPhone S M Sohan

On 2011-11-17, at 5:16 PM, jonchai reply@reply.github.com wrote:

Without embedding resource, it I can send out emails just fine. However, if I were to try the following:

PopulateBody(mailMessage, viewName: "ResetPassword", linkedResources: resources);

I get error Could not find a part of the path. I have set "/Content/images/logo.png" as my path but it points to 'C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\10.0\Content\images\logo.png' instead. Any idea how I could get this going?


Reply to this email directly or view it on GitHub: https://github.com/smsohan/MvcMailer/issues/30

jonchai commented 12 years ago

I understand that Server.MapPath is the way to go. However, Server.MapPath is not directly accessible from the Mailer class. The only way I could think of doing is to pass the path from controller to the Mailer class' constructor, but this would definitely cause some mess.

Any other workaround?

smsohan commented 12 years ago

Mailer base is a controller base and has access to http context. You can use that.


Sent from my iPhone S M Sohan

On 2011-11-17, at 5:47 PM, jonchai reply@reply.github.com wrote:

I understand that Server.MapPath is the way to go. However, Server.MapPath is not directly accessible from the Mailer class. The only way I could think of doing is to pass the path from controller to the Mailer class' constructor, but this would definitely cause some mess.


Reply to this email directly or view it on GitHub: https://github.com/smsohan/MvcMailer/issues/30#issuecomment-2784341

jonchai commented 12 years ago

Ah, yes, I see. It works now. Sorry, didn't dig deep into your codes to find out. Thank you for your help.

smsohan commented 12 years ago

Happy to help:)


Sent from my iPhone S M Sohan

On 2011-11-17, at 5:50 PM, jonchai reply@reply.github.com wrote:

Ah, yes, I see. It works now. Sorry, didn't dig deep into your codes to find out. Thank you for your help.


Reply to this email directly or view it on GitHub: https://github.com/smsohan/MvcMailer/issues/30#issuecomment-2784366

jonchai commented 12 years ago

:) Cheers.

For others who have trouble, just do base.CurrentHttpContext.Server.MapPath