View Single Post
Old 09-11-2014, 09:38 PM
python01 python01 is offline
Join Date: Jun 2008
Posts: 22
Default Sending emails from VB application like outlook

I have written an application in VB.NET which reads excel file and then sends some emails out based on the content of the file.
Although everything works fine on my home workstation with my internet provider SMTP server, at the office it is not sending any emails. When I contacted IT I received the following reply:
"In order for this to work on base workstations you would need to make sure the application can send an email much like Outlook would send SMTP emails…"
Could anyone let me know how to write code to emulate outlook? Or what steps to take to make sure my application behaves in same fashion as outlook would?
Below is my code used to send emails:

'Send email
Dim mailInstance As MailMessage = New MailMessage(fromemail, recipientemail, subject, emailbody)
Dim mailSenderInstance As SmtpClient = New SmtpClient(smtpaddress, portnumber)
mailSenderInstance.UseDefaultCredentials = False
mailSenderInstance.EnableSsl = enablessl
mailSenderInstance.Credentials = New System.Net.NetworkCredential(username, emailpassword)

Thank you for your help.
Reply With Quote