0

Have SharePoint Custom timer job using C#, It's already created and working perfect, current process - e-mails are going to user's Inbox. But I want like E-mail should go to Draft Folder of receiver.

To send e-mail Using code like below -

smtpClient = new SmtpClient();
smtpClient.Host = web.Site.WebApplication.OutboundMailServiceInstance.Server.Address;
MailMessage mailMessage = new MailMessage("email address", toEmail, subject, body);
mailMessage.IsBodyHtml = true;
smtpClient.Send(mailMessage);

May be we can use something to save e-mail at Receiver Draft folder rather using send option. These may be few lines of code change if you already did this type of task

1
  • Is this your test environment or is it live? Commented Dec 11, 2014 at 11:52

1 Answer 1

1

If this is YOUR TEST/DEVELOPER ENIVRONMENT, you can use the following method

In Web Application's web.config, change the deliveryMethod of the SMTP settings to SpecifiedPickupDirectory and give it a location to push the emails to.

<system.net>
    <mailSettings>
      <smtp deliveryMethod="SpecifiedPickupDirectory" from="[email protected]">
        <specifiedPickupDirectory pickupDirectoryLocation="C:\Work\PROJECTS\Emails" />
      </smtp>
    </mailSettings>
    <defaultProxy />
  </system.net>

That’s it. Now, all emails will be pushed to the directory you specified. This won't send the emails to user's inbox instead push it into the directory. You can still use the same code for sending the emails.

2
  • Thanks for reply, but i dont have the "pickupDirectoryLocation" of each users draft box.
    – Mahajan
    Commented Dec 11, 2014 at 14:03
  • The pickupDirectoryLocation can be a shared directory within the Network.. It won't be for each user, it will be a single directory where all emails will be dropped. Commented Dec 11, 2014 at 16:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.