I am developing a custom web part in an Office 365 environment. I am trying to send email to a user during the execution of the code in the web part.

I have tried two alternatives:

  1. SPUtility.SendEmail - doesn't work in sandbox solutions.
  2. System.Net.Mail.SmtpClient - can't get this to work, probably because the SMTP server host names that I tried are wrong. Still, the error message (something related to minimum trust) leads me to believe this cannot be made to work.

One way that I haven't tried is to create a workflow in code, which will then send the email.

Will the workflow way work and is there something that I am missing?

有帮助吗?

解决方案

The System.Net.Mail namespace works with on-premise Sandbox solutions but does not work with Office 365, so there is no way to send email from code. The "Send Email" activitiy in SharePoint Designer workflows in Office 365 does work, so yes, you can use workflow to send email.

许可以下: CC-BY-SA归因
scroll top