I am working on a SP2013 workflow custom code activity to allow sending an email with attachments, where the email attachments are the SharePoint attachments of the current list item.

I got some proof-of-concept code working where I have hardcoded the From address and the SMTP server address in the custom code activity to match what I know is set up on my development server, however, I'd ideally like to make this more flexible so it could work on any farm.

I could expose those (From address, SMTP server address) as required in arguments for the workflow custom action, but that would mean that the person creating a workflow who wanted to use that custom action would need to actually know that information.

I'd much rather set it up so that the workflow just gets whatever is configured for the web application that the current site is in.

There are two places and two technologies I could use to do this:

  1. I am using a custom declarative activity (built in VS) as a kind of wrapper for the custom code activity, so I can get things like the current site URI and current item ID, as well as using the HTTPSend activity to make a REST call to get all the attachment info for the current item, which I can then send into the custom code activity. So I can easily make other REST calls there.
  2. Once in the custom code activity, I have successfully used the C# CSOM to create a valid ClientContext using the current web URI and do various things, so I could try to get that information using the CSOM, if possible, but according to this answer here it's not actually possible to get that info via CSOM.

So - are they wrong? Is there a way to get the configured outgoing From address and SMTP server address using CSOM? Or is there a way to get that information through the REST API?

1 Answer 1


Outbound mail settings are not exposed to client-side APIs, only the server-side object model.

Your workflow will always use the farm-wide or web application outgoing mail settings.

  • "Your workflow will always use the [...] outgoing mail settings" - well, not really because my code is run by Workflow Manager, which is on a separate server and not necessarily part of the SP farm. In order to add attachments I have to new up a System.Net.Mail.MailMessage and send it through a System.Net.Mail.SmtpClient, for which I need to know the mail host name. But your first sentence definitely answers my question, thanks! Commented Dec 22, 2020 at 22:16

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.