System.Web.Mail throws error. - InfoPath Dev
in

InfoPath Dev

System.Web.Mail throws error.

Last post 09-24-2005 01:08 PM by Patrick Halstead. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 09-21-2005 04:46 PM

    System.Web.Mail throws error.

    I'm getting this error if I try to use system.mail.web in code. Does this mean my code is bad or that I can't use
    I added the system.web.dll as a reference and I put
    Imports System.Web.Mail at the top of the program....what am i missing?
    code:........................

    Dim mail As New MailMessage
    mail.To = "[email protected]"
    mail.From = "[email protected]"
    mail.Subject = "this is a test email."
    mail.Body = "this is my test email body"
    'SmtpMail.SmtpServer = "localhost" 'your real server goes here
    SmtpMail.Send(mail)



    Error........................




    System.Security.SecurityException
    Request for the permission of type System.Web.AspNetHostingPermission, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.
    at InfoPathProject2.InfoPathProject2.CTRL1_5_OnClick(DocActionEvent e)
    at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)
  • 09-22-2005 03:18 PM In reply to

    Re: System.Web.Mail throws error.

    Found the root of this issue. The form has to be "published" and then opened from it's publihsed location for the system.web.mail library to work. Of course in hindsight this makes sence...but it sure does make coding from the vs.net interface a lot slower.

    In summary...the code I posted above will work...just publish and then open the form from the published location to avoid that ugly error. Also....this works well for email alerts without using the outlook object on the client!

    Craig
  • 09-24-2005 01:08 PM In reply to

    Re: System.Web.Mail throws error.

    Hi Craig,
    You have discovered a big issue with VS and InfoPath. Another scenario that doesn't work well is debugging full trust solutions from VS.NET. Anyway, InfoPath is working on improving this for Office 12 release next year.


    Patrick Halstead [InfoPath MVP]
    InfoPathDev
    Patrick Halstead
    Project Manager at Qdabra
Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.