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(ByVal sender As System.Object, ByVal e As
System.EventArgs) 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.MailFormat.Text
.Subject = txtSubject.Text
'.Attachments=
End With
'Quel serveur utiliser?
System.Web.Mail.SmtpMail.SmtpServer = txtServer.Text
'System.Configuration.ConfigurationSettings.AppSet tings("SMTPserver")
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.Security.SecurityException' occurred
in system.windows.forms.dll
Additional information: Fail on the request for the permission of type
System.Web.AspNetHostingPermission, System, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089.
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.mail.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