This project is read-only.

Reply to an existing email

Jun 27, 2014 at 8:48 AM
Hello,
Consider the following code that is aimed at sending a message and a reply to that message:
            var message = new Message();
            message.Subject = Guid.NewGuid().ToString();
            message.BodyText = new MimeBody(new BodyFormat()) {Text = Guid.NewGuid().ToString()};
            message.To = new AddressCollection() {new Address("somebody@Gmail.com")};
            SmtpClient.SendSsl(
                message,
                "smtp.gmail.com",
                "username",
                "password",SaslMechanism.Login);
           
            var reply = new Message();
            reply.Subject = Guid.NewGuid().ToString();
            reply.BodyText = new MimeBody(new BodyFormat()) {Text = Guid.NewGuid().ToString()};
            reply.To = new AddressCollection() { new Address("somebody@gmail.com") };
            reply.InReplyTo = message.MessageId;
            SmtpClient.SendSsl(
                reply,
                "smtp.gmail.com",
                "user",
                "pass",
                SaslMechanism.Login);
But gmail and other email providers treat them as separate emails and not a single thread.
I've done similar task using MailKit library.
I've also looked at message headers and did not find anything wrong.

Thanks.