Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top