Coder Social home page Coder Social logo

Add Header as a Footer about mailbody HOT 3 CLOSED

doxakis avatar doxakis commented on August 15, 2024
Add Header as a Footer

from mailbody.

Comments (3)

doxakis avatar doxakis commented on August 15, 2024

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

from mailbody.

doxakis avatar doxakis commented on August 15, 2024

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;
}

from mailbody.

doxakis avatar doxakis commented on August 15, 2024

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

Thanks!

from mailbody.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.