|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
VB Net 2005 and Email!Having spent some time trying to get .net 2003 to send emails I'm now struggling with the 2005 version of smpt. Microsoft seem to have changed their view on the smtp side of things, before they gave a single error message for absolutely everything, now I'm getting no error message, but nothing gets sent! Can anyone tell me why the following isn't doing anything? I get my final message box, but no mail is sent! Thanks, Tull. Dim fromAddress As New MailAddress***@me.co.uk, "Info") Dim toAddress As New MailAddress***@me.co.uk, "Tull") Dim msg As New MailMessage(fromAddress, toAddress) msg.Body = "This is a test of a mail message from VB Net 2005!" msg.Subject = "Testing new email, sent at " & DateTime.Now.ToString() msg.IsBodyHtml = True Dim mailSender As New System.Net.Mail.SmtpClient() mailSender.Host = "smtp.myserver.co.uk" Try mailSender.Send(msg) Catch ex As Exception MsgBox(ex.ToString) End Try MsgBox("Mail sent") Here is what I use and it does work.
' SMTP Mail Service Dim smtpclient As New SmtpClient Dim msg As New MailMessage msg.To.Add(strMailTo.Replace(";", ",")) msg.From = New MailAddress(strMailFrom) msg.Subject = strMailSubject msg.IsBodyHtml = True Dim FileName As String FileName = Guid.NewGuid().ToString() + ".gif" Dim fs As New FileStream("C:\Export\" + FileName, FileMode.CreateNew) Dim writer As New BinaryWriter(fs) writer.Write(Attachment) writer.Flush() writer.Close() msg.Attachments.Add(New Attachment("C:\Export\" + FileName)) msg.Body = "<img border='0' src= " & FileName & " width='579' height='751'>" smtpclient.Host = "mail.hostserver.com" smtpclient.Send(msg) msg = Nothing File.Delete(FileName) Hope this helps Brian Show quoteHide quote "Tull Clancey" wrote: > Hi all. > > Having spent some time trying to get .net 2003 to send emails I'm now > struggling with the 2005 version of smpt. > > Microsoft seem to have changed their view on the smtp side of things, before > they gave a single error message for absolutely everything, now I'm getting > no error message, but nothing gets sent! > > Can anyone tell me why the following isn't doing anything? I get my final > message box, but no mail is sent! > > Thanks, > Tull. > > Dim fromAddress As New MailAddress***@me.co.uk, "Info") > Dim toAddress As New MailAddress***@me.co.uk, "Tull") > > Dim msg As New MailMessage(fromAddress, toAddress) > > msg.Body = "This is a test of a mail message from VB Net 2005!" > msg.Subject = "Testing new email, sent at " & > DateTime.Now.ToString() > msg.IsBodyHtml = True > > Dim mailSender As New System.Net.Mail.SmtpClient() > mailSender.Host = "smtp.myserver.co.uk" > > Try > mailSender.Send(msg) > Catch ex As Exception > MsgBox(ex.ToString) > End Try > > MsgBox("Mail sent") > > > Tull,
In addition to the other comments. For .NET 1.x SMTP questions see: http://www.systemwebmail.com/ For .NET 2.0 SMTP questions see: http://www.systemnetmail.com/ -- Show quoteHide quoteHope this helps Jay B. Harlow [MVP - Outlook] ..NET Application Architect, Enthusiast, & Evangelist T.S. Bradley - http://www.tsbradley.net "Tull Clancey" <tull.clan***@btopenworld.com> wrote in message news:Cp6dnTzYbbRP6zPZnZ2dnUVZ8tydnZ2d@bt.com... | Hi all. | | Having spent some time trying to get .net 2003 to send emails I'm now | struggling with the 2005 version of smpt. | | Microsoft seem to have changed their view on the smtp side of things, before | they gave a single error message for absolutely everything, now I'm getting | no error message, but nothing gets sent! | | Can anyone tell me why the following isn't doing anything? I get my final | message box, but no mail is sent! | | Thanks, | Tull. | | Dim fromAddress As New MailAddress***@me.co.uk, "Info") | Dim toAddress As New MailAddress***@me.co.uk, "Tull") | | Dim msg As New MailMessage(fromAddress, toAddress) | | msg.Body = "This is a test of a mail message from VB Net 2005!" | msg.Subject = "Testing new email, sent at " & | DateTime.Now.ToString() | msg.IsBodyHtml = True | | Dim mailSender As New System.Net.Mail.SmtpClient() | mailSender.Host = "smtp.myserver.co.uk" | | Try | mailSender.Send(msg) | Catch ex As Exception | MsgBox(ex.ToString) | End Try | | MsgBox("Mail sent") | |
Date Sort
Startup speed Regex Output to Textbox Urgent! Get rowindex - datagrid navigation Sharing Class Data With Multiple Forms Difference between MyBase and Me Need to capture all keystrokes to my application combobox view display width question Images in a Windows DataGrid How open other app from within code? |
|||||||||||||||||||||||