dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: send email using VB.NET windows Application

  1. #1
    Join Date
    Nov 2006
    Posts
    16

    send email using VB.NET windows Application

    Hi,

    I have created a windows Application using vb.net.
    sending email when click on button. Working fine when running the application on the server machine but I am having error when running from my machine.

    Using this code:

    Code:
      Try
                Dim email As New System.Web.Mail.MailMessage
                email.To = "tomail"
                email.From = "frommail"
                email.Body = "MessageText"
                email.Subject = "SubjectText"
                email.BodyFormat = Web.Mail.MailFormat.Text
                SmtpMail.SmtpServer = "MU-WEBDEV"
                SmtpMail.Send(email)
            Catch ex As Exception
                MsgBox(ex.Message)
    
            End Try
    I am getting the following error.


    An unhandled exception of type 'System.Security.SecurityException' occurred in ICP.exe

    Additional information: Request for the permission of type System.Web.AspNetHostingPermission, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.

    Can any one help me with this please. its urgent.

    Thanks.
    Last edited by HanneSThEGreaT; December 1st, 2006 at 02:20 AM. Reason: Code Tags

  2. #2
    Join Date
    Feb 2000
    Location
    OH - USA
    Posts
    1,892

    Arrow Re: send email using VB.NET windows Application

    Are you running this application from a trusted zone? It sounds like you might be running the bits from a remote location, which imposes a lot of security restrictions.

    Give your application more trust by using the framework configuration wizard, usually found in Administrative Tools.
    Good Luck,
    Craig - CRG IT Solutions - Microsoft Gold Partner

    -My posts after 08/2015 = .NET 4.x and Visual Studio 2015
    -My posts after 11/2011 = .NET 4.x and Visual Studio 2012
    -My posts after 02/2010 = .NET 4.0 and Visual Studio 2010
    -My posts after 12/2007 = .NET 3.5 and Visual Studio 2008
    -My posts after 04/2007 = .NET 3.0 and Visual Studio 2005
    -My posts before 04/2007 = .NET 1.1/2.0

    *I do not follow all threads, so if you have a secondary question, message me.

  3. #3
    Join Date
    Nov 2006
    Posts
    16

    Re: send email using VB.NET windows Application

    Hi Craig,

    Thank you for the reply.

    I tried setting the trust level but still having the error.

    Also when I open the sloution file I am getting "project location is not fully trusted by .NET run time.

    Can you please help with this.

    Thanks

  4. #4
    Join Date
    Nov 2006
    Posts
    16

    Re: send email using VB.NET windows Application

    Hi Craig,

    That worked when I have chaged the trust level on my computer.

    Thank a lot

  5. #5
    Join Date
    Nov 2006
    Posts
    16

    Re: send email using VB.NET windows Application

    Hi,

    Is there any other way of setting the trust levels. Like setting through the code.
    As this application runs on client it is not possible to set the trust level on every machine.
    Please help me doing this in another way.

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)