VB Net 2005 and Email!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tull Clancey

    #1

    VB Net 2005 and Email!

    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@ me.co.uk, "Info")
    Dim toAddress As New MailAddress(me@ me.co.uk, "Tull")

    Dim msg As New MailMessage(fro mAddress, toAddress)

    msg.Body = "This is a test of a mail message from VB Net 2005!"
    msg.Subject = "Testing new email, sent at " &
    DateTime.Now.To String()
    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.ToStr ing)
    End Try

    MsgBox("Mail sent")


  • BrianDH

    #2
    RE: VB Net 2005 and Email!

    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(strM ailTo.Replace(" ;", ","))
    msg.From = New MailAddress(str MailFrom)
    msg.Subject = strMailSubject
    msg.IsBodyHtml = True

    Dim FileName As String
    FileName = Guid.NewGuid(). ToString() + ".gif"
    Dim fs As New FileStream("C:\ Export\" + FileName, FileMode.Create New)
    Dim writer As New BinaryWriter(fs )
    writer.Write(At tachment)
    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.hostserve r.com"
    smtpclient.Send (msg)
    msg = Nothing

    File.Delete(Fil eName)

    Hope this helps

    Brian
    "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@ me.co.uk, "Info")
    Dim toAddress As New MailAddress(me@ me.co.uk, "Tull")
    >
    Dim msg As New MailMessage(fro mAddress, toAddress)
    >
    msg.Body = "This is a test of a mail message from VB Net 2005!"
    msg.Subject = "Testing new email, sent at " &
    DateTime.Now.To String()
    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.ToStr ing)
    End Try
    >
    MsgBox("Mail sent")
    >
    >
    >

    Comment

    • Jay B. Harlow [MVP - Outlook]

      #3
      Re: VB Net 2005 and Email!

      Tull,
      In addition to the other comments.

      For .NET 1.x SMTP questions see:



      For .NET 2.0 SMTP questions see:



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


      "Tull Clancey" <tull.clancey@b topenworld.comw rote in message
      news:Cp6dnTzYbb RP6zPZnZ2dnUVZ8 tydnZ2d@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@ me.co.uk, "Info")
      | Dim toAddress As New MailAddress(me@ me.co.uk, "Tull")
      |
      | Dim msg As New MailMessage(fro mAddress, toAddress)
      |
      | msg.Body = "This is a test of a mail message from VB Net 2005!"
      | msg.Subject = "Testing new email, sent at " &
      | DateTime.Now.To String()
      | 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.ToStr ing)
      | End Try
      |
      | MsgBox("Mail sent")
      |
      |


      Comment

      Working...