0
votes

I am generating emails from an SSIS package using a Script task. During testing, I do not want to really send the email, but drop the message into a folder. In an application, I would use the specifiedPickupDirectory option in the web.config, but SSIS packages do not have a web.config.

Is there a way to send the email to a folder?

Thanks

2

2 Answers

0
votes

If you script task is using C# then the following should work. It's similar to how you would change the Web.config to use specifiedPickupDirectory

SmtpClient client = new SmtpClient("my_smtp_host");
client.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
client.PickupDirectoryLocation = @"C:\save_email_directory";
client.Send(message);

You may also need to add Network credentials, see link for example

0
votes

If you use Exchange mail and this library: http://independentsoft.de/ you can create a message and move it into a specific folder.

I do not own this software, but I'm a satisfied user.

Just start here: http://independentsoft.de/exchangewebservices/tutorial/createmessage.html with this example code:

using System;
using System.Net;
using Independentsoft.Exchange;

namespace Sample
{
    class Program
    {
        static void Main(string[] args)
        {
            NetworkCredential credential = new NetworkCredential("username", "password");
            Service service = new Service("https://myserver/ews/Exchange.asmx", credential);

            try
            {
                Message message = new Message();
                message.Subject = "Test";
                message.Body = new Body("Body text");
                message.ToRecipients.Add(new Mailbox("[email protected]"));
                message.CcRecipients.Add(new Mailbox("[email protected]"));

                ItemId itemId = service.CreateItem(message);
            }
            catch (ServiceRequestException ex)
            {
                Console.WriteLine("Error: " + ex.Message);
                Console.WriteLine("Error: " + ex.XmlMessage);
                Console.Read();
            }
            catch (WebException ex)
            {
                Console.WriteLine("Error: " + ex.Message);
                Console.Read();
            }
        }
    }
}