Archived Forum Post

Index of archived forum posts

Question:

BCC Not Saved in Email MIME?

Nov 16 '15 at 10:29

First of all, great product! I love the Chilkat libraries and have been using them for quite a while now.

Unfortunately, I am now having some trouble with the Chilkat.Email class. It appears as though the BCC fields are not included in GetMime (and also GetMimeBinary). I am trying to persist a Chilkat email to disk by writing the bytes from GetMimeBinary and then reading them back in and using Email.SetFromMimeBytes to restore it to its initial state. However, when I do this, the BCC fields get stripped out of the email. If I run the following code:

        Dim chi As New Chilkat.Email
        chi.AddTo("Test", "test@hotmail.com")
        chi.AddBcc("Test", "test2@hotmail.com")
        MsgBox(chi.GetMime)
then it shows this:
        MIME-Version: 1.0
        Date: Mon, 16 Nov 2015 13:46:15 +1030
        Message-ID: 24AC72D1B6DBA501A1CC6F0ED0D921DAD96219D1@XPS-15
        Content-Type: text/plain
        Content-Transfer-Encoding: 7bit
        X-Priority: 3 (Normal)
        To: "Test" <test@hotmail.com>
Is this how it is supposed to work? If not, is there any way that it could be changed to include the BCC field?


Answer

Thanks. The difference between a "CC" recipient and a "BCC" recipient is that "BCC" is blind-carbon-copy. "blind" means that the other recipients should be unaware of the fact that the BCC recipients also received the email. If BCC is part of the MIME header, then it defeats this purpose -- because the BCC recipients can be seen.

If the application wants to persist the BCC addresses in the MIME, then a good solution is to add a header field containing the BCC recipients via the AddHeaderField method, and then call GetMime. For example:

        Dim chi As New Chilkat.Email
        chi.AddTo("Test", "test@hotmail.com")
        chi.AddBcc("Test", "test2@hotmail.com")
        chi.AddHeaderField("bcc_addrs","test2@hotmail.com")
        MsgBox(chi.GetMime)
When an app wants to load the MIME and send to the BCC addresses, it could do this:
        Dim chi As New Chilkat.Email
        chi.AddTo("Test", "test@hotmail.com")
        bccAddrs = chi.GetHeaderField("bcc_addrs")
        chi.RemoveHeaderField("bcc_addrs")
        chi.AddMultipleBcc(bccAddrs)
        ...