Home All Groups Group Topic Archive Search About

VB Net 2005 and Email!

Author
7 Jul 2006 2:58 PM
Tull Clancey
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")

Author
7 Jul 2006 3:38 PM
BrianDH
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")
>
>
>
Author
11 Jul 2006 12:16 PM
Jay B. Harlow [MVP - Outlook]
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/

--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net


Show quoteHide quote
"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")
|
|