Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. set SmtpPermission on SmtpClient user control object on an .aspx page

set SmtpPermission on SmtpClient user control object on an .aspx page

Scheduled Pinned Locked Moved ASP.NET
helpcsharpasp-netwinformssysadmin
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    GDMFSOB
    wrote on last edited by
    #1

    Can Someone help here, I am getting the following error on a Windows forms User Control running on an asp.net webpage, "request for permission of type system.net.mail.smtppermission failed", the User Control is a complied DLL and I have included it on the ASp.net page, the user control is supposed to send an email when I click send it works fine in a vb form and does run the code on the webpage but wont send the email. how do i set the SMtp Permission in my code using the SmtpPermission Class in System.Net.Mail. below is the code for sending the mail in the dll, Function SendMail(ByVal MailServer As String, ByVal mailUser As String, ByVal MailPassword As String, ByVal EmailAddress As String, ByVal Message As String, ByVal FormAddress As String, ByVal Subject As String, ByVal Port As String, ByVal Auth As Boolean) As Boolean Try Dim message1 As New MailMessage(EmailAddress, FormAddress, Subject, HttpUtility.HtmlDecode(Message).ToString) message1.IsBodyHtml = True Dim emailClient As New SmtpClient(MailServer) emailClient.UseDefaultCredentials = False ' used to authenticate the account used for sending mail If Auth = True Then Dim basicAuthenticationInfo As New System.Net.NetworkCredential(mailUser, MailPassword) emailClient.Credentials = basicAuthenticationInfo End If emailClient.Port = CInt(Port) emailClient.Send(message1) Return True Catch ex As Exception MsgBox("SendMail Failed: " & ex.Message) Return False End Try End Function I have included the dll like so on the aspx webpage <OBJECT id="SendMail2" height="193" width="527" classid="http:OCTBulkMailer.dll#OCTBulkMailer.eMailer" VIEWASTEXT > <PARAM NAME="fromAddressVal" VALUE="email"> <PARAM NAME="emailEmailSubjectVal" VALUE="Testmail from OCT Mailer"> <PARAM NAME="emailMessageVal" VALUE='<%= Message %>' > <PARAM NAME="SmtpAuthVal" VALUE="True"> <PARAM NAME="SmtpPassVal" VALUE="pass"> <PARAM NAME="SmtpUserVal" VALUE="email"> <PARAM NAME="Title" VALUE="Bulk Mailer"> <PARAM NAME="EmailAddressesVal" VALUE='<%= addresses %>'> <PARAM NAME="SmtpServerVal" VALUE="server"> <PARAM NAME="SmtpPortVal" VALUE="25"> <PARAM NAME="Instructions" VALUE="Click Start to Start sending your mails"> </OBJECT>

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups