SoulRayder SoulRayder - 12 days ago 8
C# Question

How to set delivery format while using SMTP client?

I am trying to access the DeliveryFormat property of the SMPTPClient object while programatically sending email. However, it is not recognized. I checked the MSDN documentation, which do not indicate that it has been deprecated.

SmtpClient smtpClient = new SmtpClient();
smtpClient.DeliveryFormat = SmtpDeliveryFormat.International; //DeliveryFormat property is not recognised


Is there a new way to set the delivery format property?

Dai Dai
Answer

It's not that it's been deprecated, it's that it's too new for the version you're targeting.

https://msdn.microsoft.com/en-us/library/system.net.mail.smtpdeliveryformat(v=vs.110).aspx

Version Information
.NET Framework
Available since 4.5

(emphasis mine)

Change your project to target the .NET Framework 4.5 and it will work.

This does of course mean you need to be running Visual Studio 2012 or later. If you're running 2015 then consider targeting 4.6.1.