473,583 Members | 3,413 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with send mail

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


Nov 21 '05 #1
1 1789
Sophie,

To make this nice, this is something I made as sample once for a Polish guy,
I hope you find it well that I do not change it in French? (wiadomosch is
message) It is almost the same as yours I thought, however than you can
check it yourself.

\\\
Dim wiadomosc As Web.Mail.MailMe ssage = New Web.Mail.MailMe ssage
Dim config As MailAttachment = New
MailAttachment( "c:\test1\test. txt")
wiadomosc.Attac hments.Add(conf ig)
wiadomosc.From = xxx@xxx
wiadomosc.To = xxx@xxx
wiadomosc.Subje ct = "..."
wiadomosc.Body = "..."
wiadomosc.BodyF ormat = Web.Mail.MailFo rmat.Text
System.Web.Mail .SmtpMail.SmtpS erver = "xxxx.xxxx. xx"
System.Web.Mail .SmtpMail.Send( wiadomosc)
///

The smtp server can be any smtp server that you can reach, when you have a
provider mostly even that one, altough he will probably not be lucky with
you when you use this for spam.

I hope this helps?

Cor

"Sophie" <so**********@c sp.qc.ca>
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

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3091
by: Bruce W...1 | last post by:
In my effort to learn PHP I'm playing with some simple email scripts. They worked a few days ago but they stopped working. The only thing I've done to this Windows 2000 PC in this time was a Windows Update which I do regularly. The only part of this update that might be related was an IE 6 update. So I uninstalled and reinstaled PHP 4.3.3....
15
3286
by: Steve Horrillo | last post by:
I can't figure out why this script won't insert the subject in the email and why can't I control the font and size being used? I'm not sure where to post this. Let me know where if this is OT. <SCRIPT LANGUAGE="JavaScript"> <!-- Begin function isPPC() { if (navigator.appVersion.indexOf("PPC") != -1) return true; else return false;
4
8658
by: Trond A. S. Andersen | last post by:
Hi, all! I'm trying to use the System.Web.Mail. "package" combinded with System.Web.Mail.SmtpMail in order to send MS Excel spreadsheets attached to mail messages. However, sending one single spreadsheet attachment per message, seems to be causing som kind of corruption of the attachment, while several spreadsheets per works just fine....
3
3257
by: Phil Mc | last post by:
Hi has anyone come accross the problem.... with referance to System.Web.Mail.MailMessage and System.Web.Mail.SmtpMail THIS WORKS FINE mail=new MailMessage(); mail.From = "W-MyPcName.mycompany.com"; mail.To=strTo; mail.Cc=strCC; mail.Bcc=strBCC;
5
2138
by: ElanKathir | last post by:
Hi ! I wrote one code for Send the E-mail, But that code have some problem , So please help me Here i paste my code and Error: Error: Server Error in '/Elan_Sample' Application. --------------------------------------------------------------------------------
4
6102
by: k.visube | last post by:
In my ASP application,i need to send a formatted text mail (i.e with newline characters). here in my application i used a function in javascript which construts the mail body sample snippet strbody=strbody +"dear customer,\n"; strbody=strbody +"we are glad to see ur response\n"; strbody=strbody +"we will make the needful thing as early...
3
3714
by: Pav | last post by:
Hi, I am developing a small Intranet web application which needs to send mails to our coporate Ids. I am using CDONTS, But my mails never leave Que folder. Not able to find out what the problem is . please help 1) I am very new to SMTP configiration on my own Windows XP PC. How do I configure to send mails. We Use Lotus Notes as our...
2
2796
by: joseph2000 | last post by:
Hi, I have problem with e-mails which are being send via System.Web.Mail.SmtpMail class but before describing the problem itself first I'd like to show shortly what I'm doing on the server. The following code is being executed on the server to send e-mails to clients (.NET Framework 1.1): .... EmailsInQueCollection eqc =...
1
2866
by: the_ricka | last post by:
Hi all, I'm fairly new to python, but very excited about it's potential. I'm trying to write a simple program that will accept input from a command line and send email. The parameters I used on the command line are for From address, To addresses, Subject and Body. For the body, I thought it would be better to read the input from a file so...
0
7894
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8320
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7929
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6577
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5370
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3841
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2328
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1424
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1152
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.