Click here to Skip to main content
15,916,379 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hi All,


I am getting below error in share point while sending email through event receiver, can you guide me or send snippets.


intilally i tried with below code

SmtpClient mailClient = new SmtpClient("smtp.gmail.com", 587);

and after words i tried with below

SmtpClient mailClient = new SmtpClient("smtp.gmail.com", 25);


Request for the permission of type 'System.Net.Mail.SmtpPermission, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Posted
Updated 22-Nov-15 22:20pm
v4

1 solution

This appears to be a permission / trust level setting issue in the web.config. See Error On sending Email in Asp.net on My uploaded File[^] for some more info.

As an alternative, You can use the E-Mail sharepoint is confiugred to use by using the method
C#
SPUtility.SendEmail
SPUtility.SendEmail Method - https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.utilities.sputility.sendemail(v=office.12).aspx[^]

This method allows you to use the email server that is Configured in SharePoint (the same email used for alerts and notificaitons) Central Administration.
 
Share this answer
 
Comments
kingsa 24-Nov-15 4:58am    
Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900