Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding the class SmtpDeliveryMethod

Tags:

c#

.net

email

smtp

In my code, i am sending mail from an smtp server. I use the code snippet -

SmtpClient client = new SmtpClient();
client.DeliveryMethod = SmtpDeliveryMethod.Network;

Besides Network, there are other ways too. What is the significance of these things ? The official docs don't make it clear.

like image 575
Steam Avatar asked Jan 04 '14 00:01

Steam


People also ask

Is SmtpClient obsolete?

The SmtpClient type is obsolete on some platforms and not recommended on others; for more information, see the Remarks section.

What is SMTP delivery method?

Delivery methods include: An SMTP server. Moving the email into the pickup directory for IIS, which then delivers the message. Moving the email to a directory specified by PickupDirectoryLocation for later delivery by another application.

What is SmtpClient in Asp net?

Sends the specified email message to an SMTP server for delivery. The message sender, recipients, subject, and message body are specified using String objects. SendAsync(MailMessage, Object)


1 Answers

I found the answer to my own question at - http://www.codeproject.com/Articles/66257/Sending-Mails-in-NET-Framework

Luckily, my search words accidentally landed me on the right page.

Changing Mail Delivery Method You can specify that messages sent do not go to the SMTP server. Instead, it is sent to a directory in your computer that you specify. Actually, it is a good idea when it comes to testing your application. Thus, decreases the testing time.

SmtpClient supports two properties for changing mail delivery location; they are DeliveryMethod and PickupDirectoryLocation properties. DeliveryMethod specifies the delivery method that would be taken when sending the message. This property is of type SmtpDeliveryMethod enumeration; therefore, it can be set to one of three values:

Network: (default) The message is sent via the network to the SMTP server.

PickupDirectoryFromIis: The message is copied to the mail default directory of the Internet Information Services (IIS).

SpecifiedPickupDirectory: The message is copied to the directory specified by the property PickupDirectoryLocation.

like image 68
Steam Avatar answered Sep 30 '22 03:09

Steam