|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Sending web emailI 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 i use this in all my projects
Imports System.Net.Mail Private Function fsmtpClient() As SmtpClient fsmtpClient = New SmtpClient(ConfigurationManager.AppSettings("smtpHost").ToString, Integer.Parse(ConfigurationManager.AppSettings("smtpPort"))) 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("errMailFrom")) mMsg.Priority = MailPriority.High mMsg.Body = msg Dim errto() As String = ConfigurationManager.AppSettings("errMailTo").Split(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] Show quoteHide quote "Reidar" <rei***@eivon.no> wrote in message news:OG7oxD2RGHA.256@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 > > Could you help me a bit more.
Are you placing this code in a webform with txtfields To, CC, Message, Body... or what? reidar Show quoteHide quote "m.posseth" <mich***@nohausystems.nl> skrev i melding news:uptzrs2RGHA.4456@TK2MSFTNGP14.phx.gbl... >i use this in all my projects > Imports System.Net.Mail > > Private Function fsmtpClient() As SmtpClient > > fsmtpClient = New > SmtpClient(ConfigurationManager.AppSettings("smtpHost").ToString, > Integer.Parse(ConfigurationManager.AppSettings("smtpPort"))) > > 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("errMailFrom")) > > mMsg.Priority = MailPriority.High > > mMsg.Body = msg > > Dim errto() As String = > ConfigurationManager.AppSettings("errMailTo").Split(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" <rei***@eivon.no> wrote in message > news:OG7oxD2RGHA.256@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 >> >> > > 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("Nore***@youradress.com") mMsg.Body = msg mMsg.To.Add(New MailAddress(Mailto)) Dim smtpclient As New SmtpClient("YourHost(NameOrIp)", 25) smtpclient.Send(mMsg) End Sub Show quoteHide quote "Reidar" <rei***@eivon.no> wrote in message news:Ov9C752RGHA.4608@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" <mich***@nohausystems.nl> skrev i melding > news:uptzrs2RGHA.4456@TK2MSFTNGP14.phx.gbl... >>i use this in all my projects >> Imports System.Net.Mail >> >> Private Function fsmtpClient() As SmtpClient >> >> fsmtpClient = New >> SmtpClient(ConfigurationManager.AppSettings("smtpHost").ToString, >> Integer.Parse(ConfigurationManager.AppSettings("smtpPort"))) >> >> 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("errMailFrom")) >> >> mMsg.Priority = MailPriority.High >> >> mMsg.Body = msg >> >> Dim errto() As String = >> ConfigurationManager.AppSettings("errMailTo").Split(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" <rei***@eivon.no> wrote in message >> news:OG7oxD2RGHA.256@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 >>> >>> >> >> > > "Reidar" <rei***@eivon.no> schrieb: 'System.Net.Mail' is implemented in "system.dll", not "System.Web.dll".>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 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/>
DataView Multiple Change
String builder (Parsing vertically presented records) Programming for Touch Screens I'm perplexed with simple ADO.NET - Access DB Access - Please Help Edit and Continue?? VS2005 VB6 to VB.Net - Using X1,X2,Y1,Y2 in .Net need help with regular expression Enabling / Disabling Tab Pages generating dev documentation from standard commenting. Distributing Application / SQL Server Express question |
|||||||||||||||||||||||