Hi, I'm not very good in english so excuse me if I have difficulty to
explain my problem.
I want to send a mail with VB.net with this code :
Option Strict On
Public Class Form1
Inherits System.Windows. Forms.Form
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
Try
'Votre message
Dim objMessage As New System.Web.Mail .MailMessage
With objMessage
.From = txtFrom.Text
.To = txtTo.Text
'.Cc=
'.Bcc=
.Body = txtBody.Text
.BodyFormat = Web.Mail.MailFo rmat.Text
.Subject = txtSubject.Text
'.Attachments=
End With
'Quel serveur utiliser?
System.Web.Mail .SmtpMail.SmtpS erver = txtServer.Text
'System.Configu ration.Configur ationSettings.A ppSettings("SMT Pserver")
pour choisir le smtp par défaut
'Envoi du message
System.Web.Mail .SmtpMail.Send( objMessage)
objMessage = Nothing
Catch ex As Exception
MessageBox.Show (ex.ToString)
End Try
End Sub
But I obtain this error :
An unhandled exception of type 'System.Securit y.SecurityExcep tion' occurred
in system.windows. forms.dll
Additional information: Fail on the request for the permission of type
System.Web.AspN etHostingPermis sion, System, Version=1.0.500 0.0,
Culture=neutral , PublicKeyToken= b77a5c561934e08 9.
I did a test and use the same code in a ASP application and I can send my
mail. Si I suppose it's some security on my computer but I don't know what
and nobody can help me here. Do you know how
"system.web.mai l.smtpmail.send " send the mail. What the right I need to use
this command?
Please help me I really need you!
Thank you
Have a nice day
Sophie