If you use Microsoft’s built-in SMTP service, aspNetEmail
provides the native capability to write emails directly to the Pickup directory.
Note: Because Queuing is an advanced feature of aspNetEmail, it is highly recommended to
test sending email using the standard Send() methods, BEFORE using the queuing methods. This allows for easier troubleshooting.
Along with IIS, Microsoft provides a SMTP service. This service can process emails files that are
placed, in a proprietary format, in a directory called 'Pickup'. By default, the location for this directory can be found at
C:\Inetpub\mailroot\Pickup. aspNetEmail provides the following properties and methods to write emails directly to this Pickup directory.
NOTE: In order to write emails to file system, the account using aspNetEmail must have write permissions to that directory.
[Property]
EmailMessage.MSPickupDirectory
This property allows you to manually specify the location of the Pickup directory.
[Method]
EmailMessage.SendToMSPickup()
Sends an email directly to the Pickup directory. If the directory is not specified, aspNetEmail will scan the system and attempt to locate the directory.
[Method]
EmailMessage.SendMailMergeToMSPickup()
This method is similar to SendMailMerge(), except that it will perform a mail merge, and send the resulting emails to the Pickup directory.
Both these methods have multiple overloads to accept a parameter called MSPickupDirectoryPath to manually specify the Pickup Directory.
Here are some simple code examples using SendToMSPickup()
[C#]
EmailMessage msg = new EmailMessage(); msg.FromAddress = "me@mycompany.com"; msg.To="you@yourcompany.com"; msg.Subject = "this email was sent to the MS Pickup directory."; msg.Body = "this is where the body text goes."; msg.SendToMSPickup();
[VB.NET]
Dim msg As New EmailMessage() msg.FromAddress = "me@mycompany.com" msg.To = "you@yourcompany.com" msg.Subject = "this email was sent to the MS Pickup directory." msg.Body = "this is where the body text goes." msg.SendToMSPickup()
aspNetEmail performs a number of steps to locate the MS Pickup directory. Here is an explanation of these steps, to help you optimize your use of aspNetEmail.
<appSettings>
<add key="aspNetEmail.MSPickupDirectory"
value="c:\temp\mspickup"></add>
</appSettings>
In this example, aspNetEmail will send all MS Pickup
files to a directory called c:\temp\mspickup.
For more information on
the appSettings tag, please see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/gngrfappsettingselement.asp
If none of these values can be found, or do not exist, an exception will be thrown.