Send email with Proxy

Erdenemandal

Well-known member
Joined
Jul 5, 2004
Messages
63
Location
Deutschland
Helloo, All

I have a problem to send mail. If connection is witout Proxy it works, but When I configure it with Proxy it gives me a Error ; "COULD NOT ACCES CDO:MESSAGE object"

please, help me how I can solve it. This is my Code
Code:
Public Sub SendEmail(ByVal LevelID As Integer, ByVal PRotsent As Integer)

                Dim msg As New MailMessage
                Dim d1 As DateTime

                Dim ss, ss1 As String

                Dim myIni As iniFile = New iniFile(mFileName)

                myIni.setActiveSection("general")
                ss1 = myIni.getValue("pathNotify")
                msg.From = "Test@yahoo.com"
                msg.To = ss1
                msg.Cc = ""
                msg.Bcc = ""
                msg.Priority = MailPriority.Normal

                msg.Subject = "Result of Patient " & Me.Name & " Level " & LevelID
                msg.Body = " Patient Name : " & Me.Name & Chr(13) & " PersonID  : " & Me.PersonId & Chr(13) & " Level  : " & LevelID & Chr(13) & " Result : " & PRotsent & "%" & Chr(13) & " Date : " & Format(d1.Now, "yyyy\-MM\-dd hh:mm:ss")

                If mProxy = 0 Then
                        Try

                                  ss = ss1.Substring(ss1.IndexOf("@") + 1)
                                ss = msg.From.Substring(msg.From.IndexOf("@") + 1)
                                SmtpMail.SmtpServer = "yahoo.com"
                                SmtpMail.Send(msg)

                        Catch ex As HttpException
                                MsgBox(ex.Message)
                        End Try
                End If

                
        End Sub
 
What kind of proxy are you using and where are you telling your code to use it?
If you mean there is a proxy server between yourself and the internet then it depends on the proxy configuration - most proxys will allow HTTP access out to the internet but may not be configured to allow SMTP, which you require.
You may need to speak to your ISP / Administrator / provider to see if the proxy could be reconfigured.
 
PlausiblyDamp said:
What kind of proxy are you using and where are you telling your code to use it?
If you mean there is a proxy server between yourself and the internet then it depends on the proxy configuration - most proxys will allow HTTP access out to the internet but may not be configured to allow SMTP, which you require.
You may need to speak to your ISP / Administrator / provider to see if the proxy could be reconfigured.

I means for example when I use InternetOpen function then I use Proxy parameter for InternetOPen function.

I have a proxy between Internet and my Pc you are right, I use for internet InternetOpen function, But I am not sure which function I should use for sending mail through PROXY .

When I am in worng way, let me correct

Thanks,
 
The InternetOpen function wouldnt really help in this case as I dont think you could mix calls to the unmanaged InteretOpen function and then used managed classes to send your e-mail. Also the InternetOpen function would only work with a CERN type proxy (HTTP, FTP and gopher) rather than SMTP.

You will probably need the proxy server / firewall / NAT device between you and the internet to be reconfigured to allow SMTP traffic through (port 25 needs to be opened for outbound traffic).
 
Back
Top