Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Email Exception in CRM plugin while using smtp

Posted on by Microsoft Employee

Hello All, 

I have created my own CRM plugin and installed it on CRM account. There is code where I'm attempting to send emails using my SMTP credentials. 

 smtpClient.Send(mail); throws following error.

System.Security.SecurityException: Request for the permission of type 'System.Net.Mail.SmtpPermission, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
at System.Security.CodeAccessPermission.Demand()
at System.Net.Mail.SmtpClient.Initialize()
at System.Net.Mail.SmtpClient..ctor(String host)
at TalygenCRMPlugin.Plugin.SendMail(String message, String entityType, String otherInfo)
The action that failed was:
Demand
The type of the first permission that failed was:
System.Net.Mail.SmtpPermission
The Zone of the assembly that failed was:
MyComputer

 


*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Email Exception in CRM plugin while using smtp

    I have checked community.dynamics.com/.../144242. He has talked about some other DLL. I'm dealing with System.Net.Mail.SmtpPermission.

    And in the stackoverflow link, he has not used SMTP server and credentials? Is it possible to do so?

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Email Exception in CRM plugin while using smtp

    Refer this:

    community.dynamics.com/.../144242

    http://stackoverflow.com/questions/18850903/how-to-send-an-anonymous-email-from-crm-2011-on-premises

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans