Home All Groups Group Topic Archive Search About

How to send an Email in VB.NET

Author
14 Jan 2006 3:45 PM
me
Hi all,

Does anyone have a simple SendEmail routine?

I want to be able to set the Subject, Send To address, Body and SMTP server
details (server, username, password).

Thanks

Author
14 Jan 2006 4:21 PM
Norman Crandall
You can use the system.web.mail to do exactly what you are wanting to do.

Norm


On 1/14/06 9:45 AM, in article 43c91c9a$0$23294$db0fe***@news.zen.co.uk,
Show quoteHide quote
"me" <c**@notvalid.com> wrote:

> Hi all,
>
> Does anyone have a simple SendEmail routine?
>
> I want to be able to set the Subject, Send To address, Body and SMTP server
> details (server, username, password).
>
> Thanks
>
>
Author
14 Jan 2006 4:26 PM
Herfried K. Wagner [MVP]
"me" <c**@notvalid.com> schrieb:
> Does anyone have a simple SendEmail routine?
>
> I want to be able to set the Subject, Send To address, Body and SMTP
> server details (server, username, password).

..NET 1.0/1.1:

'System.Web.Mail' (in "System.Web.dll").

..NET 2.0:

'System.Net.Mail'.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
14 Jan 2006 4:40 PM
Rotzooi
This works fine in .NET 2.0 and does not depend on CDO objects. It can be
used with independent providers because you can use authentication.

Dim msg As New System.Net.Mail.MailMessage
Dim smtp As New System.Net.Mail.SmtpClient
Dim addrFrom As New System.Net.Mail.MailAddress("f***@me.com")
Dim addrTo As New System.Net.Mail.MailAddress(***@you.com")
msg.From = addrFrom
msg.To.Add(addrTo)
msg.Subject = "Subject Text"
msg.Body = "Body Text"
smtp.Host = "smtpserver.provider.com"
smtp.Port = 25
smtp.DeliveryMethod = Net.Mail.SmtpDeliveryMethod.Network
smtp.Credentials = New System.Net.NetworkCredential("isp-username",
"isp-password")
smtp.Send(msg)


Jeroen


Show quoteHide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> schreef in bericht
news:eToh$cSGGHA.1424@TK2MSFTNGP12.phx.gbl...
> "me" <c**@notvalid.com> schrieb:
>> Does anyone have a simple SendEmail routine?
>>
>> I want to be able to set the Subject, Send To address, Body and SMTP
>> server details (server, username, password).
>
> .NET 1.0/1.1:
>
> 'System.Web.Mail' (in "System.Web.dll").
>
> .NET 2.0:
>
> 'System.Net.Mail'.
>
> --
> M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
> V B   <URL:http://classicvb.org/petition/>
Author
14 Jan 2006 11:50 PM
me
"me" <c**@notvalid.com> wrote in message
news:43c91c9a$0$23294$db0fefd9@news.zen.co.uk...
> Hi all,
>
> Does anyone have a simple SendEmail routine?
>
> I want to be able to set the Subject, Send To address, Body and SMTP
> server details (server, username, password).
>
> Thanks

Thanks all - this group is really helpful!