Email “Received” Headers

When an email is sent, it should contain no “Received” header fields. Each time the email is processed by a mail server along the delivery route, a new Received header field is prepended to the email. The very first Received header is added by the SMTP server that the SMTP client (such as your app or a program such as Outlook) connects to to send email.

A typical scenario is that an email will contain two Received headers when delivery is complete. The 1st is the Receive header added by your SMTP server. This may often be something like “localhost” and may show an internal IP address, such as “192.168.1.###”. Your SMTP server then relays the email to its destination, and the mail server at the destination (at the receiver) then adds its Received header.

The Received header has a syntax such as this:

        Received: from ? by ? via ? with ? id ? for ? ; date-time

Some mail servers may not include all the parts, and spammers often fake Received headers.

Example: How to Create an Email DSN (Delivery Status Notification)

ASP: Create DSN (Delivery Status Notification) Email
SQL Server: Create DSN (Delivery Status Notification) Email
C#: Create DSN (Delivery Status Notification) Email
C++: Create DSN (Delivery Status Notification) Email
Objective-C: Create DSN (Delivery Status Notification) Email
IOS: Create DSN (Delivery Status Notification) Email
PowerShell: Create DSN (Delivery Status Notification) Email
MFC: Create DSN (Delivery Status Notification) Email
C: Create DSN (Delivery Status Notification) Email
Delphi: Create DSN (Delivery Status Notification) Email
Visual FoxPro: Create DSN (Delivery Status Notification) Email
Java: Create DSN (Delivery Status Notification) Email
Android™: Create DSN (Delivery Status Notification) Email
Perl: Create DSN (Delivery Status Notification) Email
PHP: Create DSN (Delivery Status Notification) Email
PHP: Create DSN (Delivery Status Notification) Email
Python: Create DSN (Delivery Status Notification) Email
Ruby: Create DSN (Delivery Status Notification) Email
VB.NET: Create DSN (Delivery Status Notification) Email
Visual Basic: Create DSN (Delivery Status Notification) Email
VBScript: Create DSN (Delivery Status Notification) Email

MHT and EML are both MIME

Question:

I have added HTML email file support (thanks to your excellent examples and library), but I have a question. It appears that it might be easier for the end user to save their things they want to email as a MHT file instead of HTML out of MS-Word. That way they have one file to deal with. So is there a way to do the same method for email using and MHT file?

Answer:

MHT and EML are the exact same thing — they are both MIME.  The only difference is the file extension and the intended use of the file (as indicated by the file extension).  MHT is intended to be displayed in Internet Explorer, and EML is intended to be an email.  A .eml file will contain header files (Subject, To, From, etc.) that are not present in MHT. Therefore, to “convert” an MHT to EML, simply load it into an email object by calling LoadEml, set the Subject and From properties.  Then Add recipients by calling AddTo, AddCC, etc., and then send…

Sending SMS Text Messages via Email-to-SMS Gateways

ASP: Send SMS Message
SQL Server: Send SMS Message
C#: Send SMS Message
C++: Send SMS Message
MFC: Send SMS Message
C: Send SMS Message
Delphi: Send SMS Message
Visual FoxPro: Send SMS Message
Java: Send SMS Message
Perl: Send SMS Message
PHP: Send SMS Message
Python: Send SMS Message
Ruby: Send SMS Message
VB.NET: Send SMS Message
Visual Basic: Send SMS Message
VBScript: Send SMS Message

Understanding BCC (Blind Carbon Copy)

When an email is sent with BCC recipients, the BCC email addresses are not listed in the header.   The “To” recipients are listed in the “To” header field, and the “CC” recipients are listed in the “CC” header field, but the BCC recipients are intentionally left out.  This is what makes it a “blind” carbon copy — the recipients are unable to see the BCC recipients.  (It is by design.)  Otherwise the BCC recipients would be equivalent to “CC” recipients.  To understand how BCC recipients receive an email, I recommend reading this blog post: SMTP Protocol in a Nutshell.   The BCC recipients are passed to the SMTP server in “RCPT TO” commands.

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");

Email Attachment Not Found?

The following is a list of the most common mistakes made when expecting to find an attachment in an email object:

  1. You downloaded headers-only.  If you call a method to download only the headers of an email, then the attachments will not be included.  With IMAP you will still get information about the attachments, but with POP3 you will not get them at all.  See this blog post about POP3 email headers and attachment info.
  2. What you are expecting to see as an attachment is actually a “related item”.  A related item is an image, style sheet, etc. that is part of the HTML presentation.  It is an embedded item that is referenced by the HTML body of an email and is not a formal attachment.  You’ll find a complete set of properties and methods for related items:  NumRelatedItems, GetRelatedData, SaveRelatedItem, etc.
  3. It is an “attached message”.  Similar to related items, a complete email that is attached to another email is considered separately by Chilkat.  The property is NumAttachedMessages.  To get the Nth attached message, call GetAttachedMessage(index).  this returns a new email object that is the Nth attached message.
  4. It is an attachment found within an attached message.  You would first need to get the attached message and then you’ll see the attachments within it.