How to connect to proxy server and Send Emails (GMail)
Here is the code I use to send Emails from VB6.
Now the issue is that I've come to college and here I connect to the internet through a proxy server. So, is there a way I can send emails with Google Authentication even after being behind a proxy server?
Code:
Private Sub vSendEmail()
'Add reference to Microsoft CDO
Dim iMsg, iConf, Flds
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
' send one copy with Google SMTP server (with autentication)
schema = "http://schemas.microsoft.com/cdo/configuration/"
Flds.Item(schema & "sendusing") = 2
Flds.Item(schema & "smtpserver") = "smtp.gmail.com"
Flds.Item(schema & "smtpserverport") = 465
Flds.Item(schema & "smtpauthenticate") = 1
Flds.Item(schema & "sendusername") = "[email protected]"
Flds.Item(schema & "sendpassword") = "mypassword"
Flds.Item(schema & "smtpusessl") = 1
Flds.Update
Message = "Hello!"
With iMsg
.To = "[email protected]"
.From = "ABCD <[email protected]>"
.Subject = "Test send with GMail account"
.HTMLBody = Message
.Sender = "Myname"
.AddAttachment "C:\Test.png"
.Organization = "Myname"
.ReplyTo = "[email protected]"
Set .Configuration = iConf
SendEmailGmail = .Send
End With
Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing
MsgBox ("EMail Sent")
End Sub
Any help would be appreciated.
Re: How to connect to proxy server and Send Emails (GMail)
There is a config field defined as cdoURLProxyServer (there is no need to use the bulky String values as you are doing, since there are constants defined for all of them).
I believe this field is set to a value of the form <server>:<port>, but a simple search at MSDN should provide the details.
See http://msdn.microsoft.com/en-us/libr...exchg.10).aspx for one example.
http://msdn.microsoft.com/en-us/libr...exchg.10).aspx and http://msdn.microsoft.com/en-us/libr...exchg.10).aspx should also be useful.