3 Replies - 929 Views - Last Post: 05 January 2013 - 02:54 PM Rate Topic: -----

#1 haseeb755  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 26-December 12

SMTP : MAIL FROM LOCAL SERVER TO GMAIL how?

Posted 05 January 2013 - 08:42 AM

hi
i am developing asp application. I want that when some event occur ,EMAIL will be sent to GMAIL via my local server,

please help me to congfigure settings, and what sould be port or HOST ?

thanks
Is This A Good Question/Topic? 0
  • +

Replies To: SMTP : MAIL FROM LOCAL SERVER TO GMAIL how?

#2 AndreasD  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 14
  • Joined: 04-January 13

Re: SMTP : MAIL FROM LOCAL SERVER TO GMAIL how?

Posted 05 January 2013 - 01:46 PM

Hi there

This code should work
Imports System.Net.Mail

'Start by creating a mail message object
Dim MyMailMessage As New MailMessage()

'From requires an instance of the MailAddress type
MyMailMessage.From = New MailAddress("from_address_here@gmail.com")

'To is a collection of MailAddress types
MyMailMessage.To.Add("to_address_here@domain_name_here")

MyMailMessage.Subject = "GMail Test"
MyMailMessage.Body = "This is the test text for Gmail email"

'Create the SMTPClient object and specify the SMTP GMail server
Dim SMTPServer As New SmtpClient("smtp.gmail.com")
SMTPServer.Port = 587
SMTPServer.Credentials = New System.Net.NetworkCredential("account uid", " account pwd")
SMTPServer.EnableSsl = True

Try
   SMTPServer.Send(MyMailMessage)
   MessageBox.Show("Email Sent")
Catch ex As SmtpException
   MessageBox.Show(ex.Message)
End Try

Was This Post Helpful? 0
  • +
  • -

#3 haseeb755  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 26-December 12

Re: SMTP : MAIL FROM LOCAL SERVER TO GMAIL how?

Posted 05 January 2013 - 01:57 PM

VEry thanks,,,,, a bundle of...... ur code did a miracle,:)/>

but one thing more, I am working on HRMS system inwhich when HR and MANAGER approve leave , an email is generated QUESTION Is
in context to ur code , i might seek their credential too eg password,, which is not right legally..

please put some light on this issue,

This post has been edited by stayscrisp: 06 January 2013 - 05:46 AM
Reason for edit:: Removed quote

Was This Post Helpful? 0
  • +
  • -

#4 AndreasD  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 14
  • Joined: 04-January 13

Re: SMTP : MAIL FROM LOCAL SERVER TO GMAIL how?

Posted 05 January 2013 - 02:54 PM

Dont really get what you mean; Could you explain it a bit further?

This post has been edited by stayscrisp: 06 January 2013 - 05:47 AM
Reason for edit:: Removed unnecessary quote

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1