|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
System.Net.Mail.SmtpClient.Send Problemcode framework, fails with the 2.0 API. Any thoughts? Exception: at System.Net.Mail.SmtpClient.Send(MailMessage message) at csxlib.SmtpMessage.TestSend() in F:\Projects\Visual Studio 2005\csxlib v 0.9.7\SmtpMessage.vb:line 124 at Mail_Test.Module1.Main() in F:\Projects\Visual Studio 2005\Mail Test\Mail Test\Mail Test\Module1.vb:line 9 at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()" Here is the code: Public Sub TestSend() Dim client As SmtpClient = New SmtpClient("localhost") Dim froom As MailAddress = New MailAddress***@d.com", "c", System.Text.Encoding.UTF8) ' Set destinations for the e-mail message. Dim too As MailAddress = New MailAddress***@b.com") ' Specify the message content. Dim message As MailMessage = New MailMessage(froom, too) message.Body = "This is a test e-mail message sent by an application. " ' Include some non-ASCII characters in body and subject. message.Body += Environment.NewLine + ">>>>>>>>>>>>>>>>>>>" message.BodyEncoding = System.Text.Encoding.UTF8 message.Subject = "test message 1" + "<<<<<<<<<<<<<<<<" message.SubjectEncoding = System.Text.Encoding.UTF8 client.Send(message) message.Dispose() End Sub I have a complete 1.1 and 2.0 email send code you can download at:
http://spaces.msn.com/sholliday/ 2/8/2006 entry The syntax of 2.0 is definately different. Please post (here) if you figure out what it was. Show quote "george" <geo***@discussions.microsoft.com> wrote in message news:F1363293-3D77-4213-87AF-B8FBB704DB0F@microsoft.com... > This box sends email all the time with a localhost smtp address on .NET 1.1 > code framework, fails with the 2.0 API. Any thoughts? > > Exception: > > at System.Net.Mail.SmtpClient.Send(MailMessage message) > at csxlib.SmtpMessage.TestSend() in F:\Projects\Visual Studio 2005\csxlib > v 0.9.7\SmtpMessage.vb:line 124 > at Mail_Test.Module1.Main() in F:\Projects\Visual Studio 2005\Mail > Test\Mail Test\Mail Test\Module1.vb:line 9 > at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args) > at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence > assemblySecurity, String[] args) > at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() > at System.Threading.ThreadHelper.ThreadStart_Context(Object state) > at System.Threading.ExecutionContext.Run(ExecutionContext > executionContext, ContextCallback callback, Object state) > at System.Threading.ThreadHelper.ThreadStart()" > > > Here is the code: > > Public Sub TestSend() > Dim client As SmtpClient = New SmtpClient("localhost") > Dim froom As MailAddress = New MailAddress***@d.com", "c", > System.Text.Encoding.UTF8) > ' Set destinations for the e-mail message. > Dim too As MailAddress = New MailAddress***@b.com") > ' Specify the message content. > Dim message As MailMessage = New MailMessage(froom, too) > message.Body = "This is a test e-mail message sent by an > application. " > ' Include some non-ASCII characters in body and subject. > > message.Body += Environment.NewLine + ">>>>>>>>>>>>>>>>>>>" > message.BodyEncoding = System.Text.Encoding.UTF8 > message.Subject = "test message 1" + "<<<<<<<<<<<<<<<<" > message.SubjectEncoding = System.Text.Encoding.UTF8 > client.Send(message) > > message.Dispose() > > End Sub > |
|||||||||||||||||||||||