By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,492 Members | 1,289 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,492 IT Pros & Developers. It's quick & easy.

Sending web email

P: n/a
I am trying to send web email in vs2005, but haven't succeeded so far.
I found an example in C# to make a Console application.
The top of the code is
using System;
using System.Web.Mail;
I have added a reference System.Web.
When I run the code I get warnings saying that System.Web.MailMessage is
'obsolete'.
Alternative is System.Net.Mail.MailMessage
When I change the System.Web.Mail to System.Net.Mail, I can't find any
reference for System.Net.Mail
Does anybody have a good example to follow just to send a plain web email
whith From, To, Message, Body and Attachment.
Preferrably in Vb.

regards
reidarT
Mar 14 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
i use this in all my projects
Imports System.Net.Mail

Private Function fsmtpClient() As SmtpClient

fsmtpClient = New
SmtpClient(ConfigurationManager.AppSettings("smtpH ost").ToString,
Integer.Parse(ConfigurationManager.AppSettings("sm tpPort")))

fsmtpClient.UseDefaultCredentials = True

End Function

Public Shared Sub adminErrorMail(ByVal msg As String, Optional ByVal
Notification As Boolean = False)

Dim mMsg As New MailMessage

If Notification Then

mMsg.Subject = "H-base.com Notification : " & Now.ToString

Else

mMsg.Subject = "H-base.com Application error occured : " & Now.ToString

End If

mMsg.From = New MailAddress(ConfigurationManager.AppSettings("errM ailFrom"))

mMsg.Priority = MailPriority.High

mMsg.Body = msg

Dim errto() As String =
ConfigurationManager.AppSettings("errMailTo").Spli t(CChar(";"))

For Each adress As String In errto

mMsg.To.Add(New MailAddress(adress))

Next

fsmtpClient.Send(mMsg)

End Sub

this works perfect :-)

regards

Michel posseth [MCP]

"Reidar" <re****@eivon.no> wrote in message
news:OG*************@TK2MSFTNGP14.phx.gbl...
I am trying to send web email in vs2005, but haven't succeeded so far.
I found an example in C# to make a Console application.
The top of the code is
using System;
using System.Web.Mail;
I have added a reference System.Web.

When I run the code I get warnings saying that System.Web.MailMessage is
'obsolete'.
Alternative is System.Net.Mail.MailMessage
When I change the System.Web.Mail to System.Net.Mail, I can't find any
reference for System.Net.Mail
Does anybody have a good example to follow just to send a plain web email
whith From, To, Message, Body and Attachment.
Preferrably in Vb.

regards
reidarT

Mar 14 '06 #2

P: n/a
Could you help me a bit more.
Are you placing this code in a webform with txtfields To, CC, Message,
Body...
or what?
reidar
"m.posseth" <mi*****@nohausystems.nl> skrev i melding
news:up**************@TK2MSFTNGP14.phx.gbl...
i use this in all my projects
Imports System.Net.Mail

Private Function fsmtpClient() As SmtpClient

fsmtpClient = New
SmtpClient(ConfigurationManager.AppSettings("smtpH ost").ToString,
Integer.Parse(ConfigurationManager.AppSettings("sm tpPort")))

fsmtpClient.UseDefaultCredentials = True

End Function

Public Shared Sub adminErrorMail(ByVal msg As String, Optional ByVal
Notification As Boolean = False)

Dim mMsg As New MailMessage

If Notification Then

mMsg.Subject = "H-base.com Notification : " & Now.ToString

Else

mMsg.Subject = "H-base.com Application error occured : " & Now.ToString

End If

mMsg.From = New
MailAddress(ConfigurationManager.AppSettings("errM ailFrom"))

mMsg.Priority = MailPriority.High

mMsg.Body = msg

Dim errto() As String =
ConfigurationManager.AppSettings("errMailTo").Spli t(CChar(";"))

For Each adress As String In errto

mMsg.To.Add(New MailAddress(adress))

Next

fsmtpClient.Send(mMsg)

End Sub

this works perfect :-)

regards

Michel posseth [MCP]

"Reidar" <re****@eivon.no> wrote in message
news:OG*************@TK2MSFTNGP14.phx.gbl...
I am trying to send web email in vs2005, but haven't succeeded so far.
I found an example in C# to make a Console application.
The top of the code is
using System;
using System.Web.Mail;
I have added a reference System.Web.

When I run the code I get warnings saying that System.Web.MailMessage is
'obsolete'.
Alternative is System.Net.Mail.MailMessage
When I change the System.Web.Mail to System.Net.Mail, I can't find any
reference for System.Net.Mail
Does anybody have a good example to follow just to send a plain web email
whith From, To, Message, Body and Attachment.
Preferrably in Vb.

regards
reidarT


Mar 14 '06 #3

P: n/a
Well i have placed the code in a public class so all my pages can use it
( it was a actuall copy paste of functioning code in one of my projects )

here is a simplified version in one method

Public Shared Sub SendMail(ByVal msg As String, ByVal Mailto As String)

Dim mMsg As New MailMessage

mMsg.Subject = "Your Subject"

mMsg.From = New MailAddress("No*****@youradress.com")

mMsg.Body = msg

mMsg.To.Add(New MailAddress(Mailto))

Dim smtpclient As New SmtpClient("YourHost(NameOrIp)", 25)

smtpclient.Send(mMsg)

End Sub


"Reidar" <re****@eivon.no> wrote in message
news:Ov**************@tk2msftngp13.phx.gbl...
Could you help me a bit more.
Are you placing this code in a webform with txtfields To, CC, Message,
Body...
or what?
reidar
"m.posseth" <mi*****@nohausystems.nl> skrev i melding
news:up**************@TK2MSFTNGP14.phx.gbl...
i use this in all my projects
Imports System.Net.Mail

Private Function fsmtpClient() As SmtpClient

fsmtpClient = New
SmtpClient(ConfigurationManager.AppSettings("smtpH ost").ToString,
Integer.Parse(ConfigurationManager.AppSettings("sm tpPort")))

fsmtpClient.UseDefaultCredentials = True

End Function

Public Shared Sub adminErrorMail(ByVal msg As String, Optional ByVal
Notification As Boolean = False)

Dim mMsg As New MailMessage

If Notification Then

mMsg.Subject = "H-base.com Notification : " & Now.ToString

Else

mMsg.Subject = "H-base.com Application error occured : " & Now.ToString

End If

mMsg.From = New
MailAddress(ConfigurationManager.AppSettings("errM ailFrom"))

mMsg.Priority = MailPriority.High

mMsg.Body = msg

Dim errto() As String =
ConfigurationManager.AppSettings("errMailTo").Spli t(CChar(";"))

For Each adress As String In errto

mMsg.To.Add(New MailAddress(adress))

Next

fsmtpClient.Send(mMsg)

End Sub

this works perfect :-)

regards

Michel posseth [MCP]

"Reidar" <re****@eivon.no> wrote in message
news:OG*************@TK2MSFTNGP14.phx.gbl...
I am trying to send web email in vs2005, but haven't succeeded so far.
I found an example in C# to make a Console application.
The top of the code is
using System;
using System.Web.Mail;
I have added a reference System.Web.

When I run the code I get warnings saying that System.Web.MailMessage is
'obsolete'.
Alternative is System.Net.Mail.MailMessage
When I change the System.Web.Mail to System.Net.Mail, I can't find any
reference for System.Net.Mail
Does anybody have a good example to follow just to send a plain web
email whith From, To, Message, Body and Attachment.
Preferrably in Vb.

regards
reidarT



Mar 14 '06 #4

P: n/a
"Reidar" <re****@eivon.no> schrieb:
I am trying to send web email in vs2005, but haven't succeeded so far.
I found an example in C# to make a Console application.
The top of the code is
using System;
using System.Web.Mail;
I have added a reference System.Web.
When I run the code I get warnings saying that System.Web.MailMessage is
'obsolete'.
Alternative is System.Net.Mail.MailMessage
When I change the System.Web.Mail to System.Net.Mail, I can't find any
reference for System.Net.Mail


'System.Net.Mail' is implemented in "system.dll", not "System.Web.dll".

Additional information:

<URL:http://msdn2.microsoft.com/en-us/library/system.net.mail.mailmessage(VS.80).aspx>

<URL:http://www.systemnetmail.net/>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Mar 14 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.