Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Html Helpers not working from console application #165

Open
VickyMahir opened this issue Nov 8, 2016 · 4 comments
Open

Html Helpers not working from console application #165

VickyMahir opened this issue Nov 8, 2016 · 4 comments

Comments

@VickyMahir
Copy link

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

@austindenz412
Copy link

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.

@christhomas412
Copy link

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.

@jhoncarles725
Copy link

Have you checked if the console application has access to necessary resources, such as the tyre pressure image files, and if there are any differences in how Postal is configured between the two applications? That could help pinpoint the issue.

@jackjhones12
Copy link

jackjhones12 commented Jun 15, 2024

Had the same issue! Switching to a web context explore fixed it for me. Anyone found a console-specific workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants