I am trying to authenticate email through SMTP, which I was allways able to do in VB 2003 wihtout too much trouble.
Now in 2005 I cannot get it done. Here is my code (based on the example from this thead:
It is VB2005 and I am using Vista as my OS just in case things may be different on that platform. Also the SMTP address is a POP3 email account (provided by the ISP on a domain using Shared Hosting)Code:Private Sub EmailDistrict1( _ ByVal StrMailFrom As String, _ ByVal strMailTo1 As String, _ ByVal strMailTo2 As String, _ ByVal strMailTo3 As String, _ ByVal strMailTo4 As String, _ ByVal strMailTo5 As String, _ ByVal strmailto6 As String, _ ByVal StrSubject As String, _ ByVal StrBody As String, _ ByVal strFPath As String) Dim message As New MailMessage message.From = New MailAddress(StrMailFrom) message.To.Add(strMailTo1) message.To.Add(strMailTo2) message.To.Add(strMailTo3) message.To.Add(strMailTo4) message.To.Add(strMailTo5) message.To.Add(strmailto6) message.Subject = StrSubject message.Body = StrBody Dim emailClient As New SmtpClient(strMailServer) emailClient.Credentials = (SMTP_Credentials) ' Formatted as ("User", "Pass") emailClient.DeliveryMethod = SmtpDeliveryMethod.Network emailClient.UseDefaultCredentials = False Try emailClient.Send(message) Catch ex As Exception MessageBox.Show(ex.Message & vbNewLine & ex.stacktrace) End Try End Sub


Reply With Quote