Search code examples
.netvb.netemailsmtpsmtpclient

SMTP - adding headers


I am trying to create an application in which I can reply to emails. I am using the smtp library to send the emails. What I am trying to achieve is creating an email tread. I am trying to do this by setting the "Reference" header before sending the email. I am trying the following:

mailMsg.Headers.Add("References", Header)

The value of variable header is: <CAAPa+tw4HWCFbCO89FmTP+U4gbfD46wsbjzy=_sLK9hu=KuoRA@mail.gmail.com>

But I am getting the following error: An invalid character was found in header name. and it does not specify which character. Any help would be greatly appreciated since very little material on this matter is available.


Solution

  • After further testing and tweaking the correct format should be:

     mailMsg.Headers.Add("In-Reply-To", Header)