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

Add Header as a Footer #4

Closed
FanMix opened this issue Mar 6, 2017 · 3 comments
Closed

Add Header as a Footer #4

FanMix opened this issue Mar 6, 2017 · 3 comments

Comments

@FanMix
Copy link

FanMix commented Mar 6, 2017

It'll be great if you add Header as text or/and a logo image is presented in here
https://htmlemail.io/img/preview-password.jpg

Any way you this template is in use.

THANKS !!!

@FanMix FanMix changed the title Add Header with by template Add Header as a Footer Mar 6, 2017
@doxakis
Copy link
Owner

doxakis commented Mar 6, 2017

Hi,
It looks like a great idea. I'm just not sure how it will be implemented.
I will do some research first.

@doxakis
Copy link
Owner

doxakis commented Mar 8, 2017

Hi,
I added the possibility to add image. (It uses width:100%)
There are many way to reference image : CID Embedded Images, Base64 Encoding or use absolute url.
I would prefer absolute url if I have to choose.
I added a new example in the readme.

Here some examples if you use postmark (with the package https://www.nuget.org/packages/postmark) :

private void Method1(PostmarkMessage message)
{
	// Absolute url.
	// Work on gmail, hotmail.com
	// Doesn't work on Outlook

	var html = MailBody.CreateBody()
		.Image("https://placehold.it/540x70/ffffff/e8117f?text=My+logo", "My company name")
		.Paragraph("Please confirm your email address by clicking the link below.")
		.Paragraph("We may need to send you critical information about our service and it is important that we have an accurate email address.")
		.Button("https://example.com/", "Confirm Email Address")
		.Paragraph("— [Insert company name here]")
		.GenerateHtml();
	message.HtmlBody = html;
}

private void Method2(PostmarkMessage message)
{
	// CID Embedded Images
	// Work on hotmail.com, Outlook
	// Doesn't work well on gmail. (appear as email attachment)

	var html = MailBody.CreateBody()
		.Image("cid:embed_logo.jpg", "My company name")
		.Paragraph("Please confirm your email address by clicking the link below.")
		.Paragraph("We may need to send you critical information about our service and it is important that we have an accurate email address.")
		.Button("https://example.com/", "Confirm Email Address")
		.Paragraph("— [Insert company name here]")
		.GenerateHtml();
	message.HtmlBody = html;

	var imageContent = System.IO.File.ReadAllBytes(Server.MapPath("~/logo.jpg"));
	message.AddAttachment(imageContent, "logo.jpg", "image/jpg", "embed_logo.jpg");
}

private void Method3(PostmarkMessage message)
{
	// Base64 Encoding.
	// Work on hotmail.com
	// Doesn't work on gmail, Outlook

	var imageContent = Convert.ToBase64String(System.IO.File.ReadAllBytes(Server.MapPath("~/logo.png")));
	var src = "data:image/png;base64," + imageContent;

	var html = MailBody.CreateBody()
		.Image(src, "My company name")
		.Paragraph("Please confirm your email address by clicking the link below.")
		.Paragraph("We may need to send you critical information about our service and it is important that we have an accurate email address.")
		.Button("https://example.com/", "Confirm Email Address")
		.Paragraph("— [Insert company name here]")
		.GenerateHtml();
	message.HtmlBody = html;
}

@doxakis
Copy link
Owner

doxakis commented Jul 8, 2017

I will close this issue for now. If you have any problem, please create a new issue.

Thanks!

@doxakis doxakis closed this as completed Jul 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants