I am sending mail with:
var spContext = SharePointContextProvider.Current.GetSharePointContext(Context);
using (var clientContext = spContext.CreateUserClientContextForSPHost())
{
var emailp = new EmailProperties();
emailp.BCC = new List<string>{"[email protected]"};
emailp.To = new List<string>{"[email protected]"};
emailp.From = "[email protected]";
emailp.Body = "<b>html</b>";
emailp.Subject = "subject";
Utility.SendEmail(_clientContext, emailp);
_clientContext.ExecuteQuery();
}
The mail is sent but the from address is ignored and my servers from address is used. Can I use a from address with Utility.SendEmail? When I convert my code to use the .NET framework SMTP class the from address is respected.
Update
When I set my servers from email address in the outgoing email settings in central admin to empty I get the exception: The parameter 'address' cannot be an empty string. Parameter name: address. This happens even when I set emailp.From = "[email protected]"