Forwarding mailmessage object as attachment

0 votes
asked Apr 15, 2015 by rockyshah2015 (750 points)
edited Apr 15, 2015 by Tomas Knopp

I am sending mail message object as an attachment as below code but when I receive the forwarded email i cant see bcc?? why?? i can only see cc

// an e-mail we just received
MailMessage original = imap.GetMailMessage(sequenceNumber);

// create a new message
MailMessage forward = new MailMessage();

// initialize it
forward.To = "mary@example.org";
forward.From = "peter@example.org";
forward.Subject = "FW: " + original.Subject;
forward.BodyText = "Hello, I am forwarding this to you!";

// and add the original e-mail as an attachment
forward.Attachments.Add(new Attachment(original));

// we are now ready to send the message
Applies to: Rebex Secure Mail
commented Apr 16, 2015 by Tomas Knopp (58,580 points)
So if I understand your problem correctly - you get the original email, which contains some BCC recipients. Then you add it as an attachment to another email and send it to some test account. After you receive the mail, and open the attached emails no BCC field is present?

1 Answer

0 votes
answered Apr 16, 2015 by Tomas Knopp (58,580 points)

Hello,

actually I have tested your code, sent the message and after I received it from the server, the BCC headers in the attached eml actually stayed there...

Try my code:

        // get mail with BCC from the server
        MailMessage original = imap.GetMailMessage(sequenceNumber);

        // see whether it contains the BCC header
        if (original.Bcc.Count == 0)
            Console.WriteLine("No BCC found in original email.");
        else
            Console.WriteLine("BCC header = '{0}'", original.Bcc);

        // new message
        MailMessage forward = new MailMessage();

        // initialize it
        forward.To = "mary@example.org";
        forward.From = "peter@example.org";
        forward.Subject = "FW: " + original.Subject;
        forward.BodyText = "Hello, I am forwarding this to you!";

        // add the original e-mail as an attachment
        forward.Attachments.Add(new Attachment(original));

        // send message
        Smtp smtp = new Smtp();
        smtp.Connect("SMTP-server");
        smtp.Login("user", "password");

        smtp.LogWriter = new Rebex.FileLogWriter(@"C:\temp\log.txt", LogLevel.Verbose);
        smtp.Send(forward, "from@domain.com", "to@domain.com");
        smtp.Disconnect();

If you do not get the BCC header in the attached email, just look into the verbose log and see whether the BCC header was there when sending by Rebex Smtp.

...