Appending to an email body
Here is a C# example to append more text to an email’s body:
Chilkat.Email email = new Chilkat.Email(); bool success = email.LoadEml("in.eml"); if (!success) { textBox1.Text = email.LastErrorText; return; } // Does this email have a plain-text body? if (email.HasPlainTextBody()) { string s = email.GetPlainTextBody(); s += "\r\nMore text appended to the email's plain-text body."; // Replace the plain-text body: if (email.HasHtmlBody()) { // This is an email with both plain-text and HTML alternatives // The AddPlainTextAlternative body replaces the plain-text body if it already exists. email.AddPlainTextAlternativeBody(s); } else { // This is a plain-text only email. email.Body = s; } } if (email.HasHtmlBody()) { string s = email.GetHtmlBody(); s += "<p>More text appended to the email's plain-text body.</p>"; // Replace the HTML body: if (email.HasPlainTextBody()) { // This is an email with both plain-text and HTML alternatives // The AddHtmlAlternativeBody replaces the HTML body if it already exists. email.AddHtmlAlternativeBody(s); } else { // This is an HTML-only email. email.SetHtmlBody(s); } } email.SaveEml("out.eml");
admin
0
Tags :