Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Firewalls, how does my app get out?

Status
Not open for further replies.

tacs

Programmer
Nov 21, 2005
46
GB
I have been reading the FAQs and with help from you guys I am slowly building up what little knowledge I have on automating Outlook and then using CDO and SMTP to create emails from within my app.

My first attempts worked on my desktop which shares it's internet connection, but not on my laptop which was using that shared connection. I then started using this code and it works fine here, but not on my colleagues site in the USA. After a while the penny dropped that it was getting stuck in the firewall.

Can anyone tell me what I need to do in order to allow the guys in the USA to set up some parameters to get through the firewall.



FUNCTION test_email()
PARAMETERS cSender, cECopies, cSubj, cMsg, cParam, cServer

Local iMsg,iConf
Declare SHORT InternetGetConnectedState In wininet.Dll;
INTEGER @lpdwFlags, Integer dwReserved

*Check for an active internet connection
lConnect=displayState()

* If we have a connection create and send the email
If lConnect
iMsg = Createobject("CDO.Message")
iConf = Createobject("CDO.Configuration")
Flds = iConf.Fields
With Flds
.Item(" = 2
.Item(" = cServer
.Item(" .Update
Endwith
With iMsg
.Configuration = iConf
.To = cRecipient
.CC = cECopies
.BCC = ""
.From = cSender
.Subject = cSubj
.TextBody = cMsg
.Send
Endwith
iMsg = .Null.
iConf = .Null.
wb = .Null.
ELSE
IF cParam != 2 .or. cParam != 4
Messagebox("Could not send the message, your internet connection is down.")
ENDIF
ENDIF

Procedure displayState
Local lConnected
lConnected = .F.
lpdwFlags = 0
If InternetGetConnectedState (@lpdwFlags, 0) = 1
lConnected = .T.
Endif
Return lConnected



Thanks in advance.
 

Do you get an error message?

Which part is not happening? You sending or him receiving? Or him sending?

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
Yes, sorry, there's an error message. "OLE IDispatch exception code 0 from CDO Message 1: The transport failed to connect to the server".

The problem is when he is trying to send email to me.

One more thing. I know that he has CDO installed because I put a test into the program as per one of the FAQs. It tells me that "CDO version installed is 1.21" which it also says on the computers over here that I tried and suceeded in sending mail from over here. We tried this at my colleagues home and it was fine, but at work I'm pretty sure it must be stuck behind the firewall.
 
Have hime try this code to see what happens.

Code:
oCDO2 = createobject(‘cdo.message’)
With oCDO2
    .Subject = ‘My subject’ 
    .From = ‘Mike Gagnon’  && De la part de. 
    .To = ‘you@somewhere.com’
    .Sender =’me@somwhereelse.com’
    .TextBody=This is the body’ 
Endwith
oCDO2.send()



Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
Thanks Mike

I'll send it over and let you know what happens.

 
Mike that's great, it worked.

Thanks very much.
 
Sorry, Mike, but I have another question for you.

I just ran the test code on my laptop that uses a shared internet connection and the test failed. I got the same error message

"OLE IDispatch exception code 0 from CDO Message 1: The transport failed to connect to the server".

as my colleague in the USA was getting on the original code, but that worked on this laptop.

Is this because it's using a shared connection and is there a way to detect this so that you can use either of the sets of code according to the connection type?

Thanks again Mike.
 

No, the code requires an SMTP service running. I have a feeling he has one running on his system and you do not. I he has IIS installed on his system, there is a chance that at the sametime and SMTP service was installed. In your case it would seems you do not have one running, that is the reason you need to use an external one.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
I see, so I was thinking it was CDO that was the problem, but it isn't of course.

OK. So the question should be then, is there a way to see if IIS is running so that if it isn't installed on any of the other machines I can get the code that runs without it to be called instead?

 
Not that can think of. But CDO like most other mail transport engine needs to point to a place where it can get out. For example when you first configure Outlook, you need to specify the POP and the SMTP setting, the same goes for BLAT, MAPI, Winsock etc...Unless you trap the error and once the error is trapped, switch code, but if he has neither one, nothing will go. When we install e-mail capability to our applications, this is the part were we get involved and store the SMTP settings in a table and use those, we do not let the application search for a possible way out.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
I had already thought about that. In fact the program already allows the user to enter the SMTP and POP settings, just like Outlook. What I don't understand, though, is what affect this has in the code which now works in the USA as it doesn't ask for any of that information.

I can understand it in my original code, because that info gets passed through to the email section (the parameter list) so it knows what SMTP server to use etc. The problem is just that it doesn't always work!!

Your code works fine there, but not on my Laptop. My development PC is happy with both versions, hence the confusion.
 
Your code works fine there, but not on my Laptop. My development PC is happy with both versions, hence the confusion.

As far as I know, IIS and SMTP service, can only be installed on Windows XP professional. Do you have Windows XP professional? (Although there is a hack to make it work on XP home edition). If you have XP pro, you can install IIS and an SMTP service on your laptop and use the suggested code.


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
I just checked and the laptop uses XP Pro, but it did origonally have XP Home on it when we bought it and I can remember upgrading it to Pro. Maybe the upgrade didn't install IIS and SMTP.

If that's the problem then it's fine as most of the PCs have Windows XP Pro. Although, there are some Win2k PCs about as well, so that could cause a problem. I'm just trying out the error trap to see if I can catch it and divert it to the other email option.

Thanks again.
 
OK, this seems to be working on both of my computers.

If I use the code you supplied as the default email method and surround the send() command with new ON ERROR handling then if send() fails it goes to a function with the alternate email method before returning to the nomal error handling method after send(). It seems to work happily.

ON ERROR do USEALTMAIL with cSubj, cMsg, cParam, cServer, ;
cSender, cFrom, cEmTo, cECopies
oCDO2.send()
ON ERROR

Thanks Mike for all your help.
 
I just checked and the laptop uses XP Pro, but it did origonally have XP Home on it when we bought it and I can remember upgrading it to Pro. Maybe the upgrade didn't install IIS and SMTP.

This is not done be default.Its an option

If you have not done so, take a look at other options for sending with CDO faq184-1768.


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top