Html Helpers not working from console application
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 = "[email protected]",
From = "[email protected]"
};
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 = "[email protected]",
From = "[email protected]"
};
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
Hi,
It seems like the issue lies in integrating Postal for sending emails in a console application. In your console application, ensure that the path to your view in 'FileSystemRazorViewEngine' is correct and Best Golf accessible. Additionally, confirm that the required dependencies and configurations for Postal are properly set up in the console application.
Best regards.
Hi, It seems like you're encountering an issue where sending emails with embedded images works in the MVC web application but not in the console application. To troubleshoot this, ensure the correct path to the view is specified and the image is properly embedded in the console application. Check if the Apk path to the image is accessible in the console application and adjust accordingly. Also, make sure the ExampleEmail class and its usage are consistent in both applications. Double-check the registration of the email service and any configurations specific to the console application.