andrewdavey / andrewdavey/postal
Html Helpers not working from console application
- Vorherrschende Sprache
- C#
- Sterne
- 534
- Forks
- 164
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
Hi,
I have one console application and one mvc web application.
That two application use one common class library to send mail using postal.
From web its working send email with html embedding image but in console application its not working.
I have do as per below
**Class Library Project :**
`PostalEmailSenderService.cs` File
```
public bool FromWebEmail()
{
var email = new ExampleEmail
{
Subject = "Welcome Mail",
To = "test@test.com",
From = "test@test.com"
};
email.Send();
return true;
}
public bool FromConsoleEmail()
{
var viewsPath = Path.GetFullPath(@"..\MyWebApplicationDirectory\Views\Emails");
var engines = new ViewEngineCollection();
engines.Add(new FileSystemRazorViewEngine(viewsPath));
EmailService service = new EmailService(engines);
var email = new ExampleEmail
{
Subject = "Welcome Mail",
To = "test@test.com",
From = "test@test.com"
};
service.Send(email);
return true;
}
```
**Web Application Project :**
```
PostalEmailSenderService ps = new PostalEmailSenderService(true);
ps.FromWebEmail();
```
**Console Application Project :**
```
PostalEmailSenderService ps = new PostalEmailSenderService(true);
service.RegistrationEmail();
```
**Emails\Example.cshtml** - This file is in my web application.
```
To:@Model.To
Subject:@Model.Subject
I am just test my email from web and console aplication
@Html.EmbedImage("~/Content/IMGMail.jpg")
```
Web application and Console Application use Same View is in Web Application.
So please tell me how to do this ?
Thanks
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Bewertung
Dieses Issue wurde noch nicht bewertet.