Solved

CDOSYS Woes

Posted on 2002-05-28
9
1,488 Views
Last Modified: 2008-02-01
I'm putting all my points on this one in the hopes that i can finally get some questions answered about my CDOSYS problems.  I've been writing applications for my employer that send emails programmatically, and I've been using CDOSYS.  While experimenting with the package I discovered a major problem : that there seemed to be a difference between the emails sent to people within the company (our mail is provided by an MS exchange 5.5 server) and those sent to addresses outside of the company (I am guessing because they are outside of our firewall, but i don't know.)

After endless experimentation and frustration i discovered that a CDO.Message that referenced our main server (NT server 4 with MS exchange 5.5) as it's mail server would deliver messages internally to the company.  Another machine on the network, running IIS and win2k, would deliver external messages when referenced.  (to be thorough: the NTS machine cannot deliver external mail, and the win2k machine cannot deliver internal mail.)

Given a long list of emails, it's a pretty big pain in the butt for every program that i write to have to sort them into local and external addresses, then send the messages to two different servers.

Not only this : as of three days ago, the computer that I use to send external messages stopped working.  The emails began bouncing back with the error message "Unable to deliver message to the following recipients, due to being unable to connect successfully to the destination mail server."

I would like to get to the bottom of all this trouble and just use one mail server to send emails programmatically, something that is supposed to be easy with CDOSYS.  Below is a sample of the code I use to send messages.  The successful answer will receive 385 points + my eternal gratitude.

----------------------------------------------

Set extMailConfig = New CDO.Configuration
Set Flds = extMailConfig.Fields
With Flds
  .Item(cdoSendUsingMethod) = cdoSendUsingPort
  .Item(cdoSMTPServer) = (win2k/IIS Machine)
  .Item(cdoSMTPConnectionTimeout) = 30
  .Item(cdoSMTPServerPort) = 25
  .Item(cdoSMTPAuthenticate) = cdoAnonymous
  .Update
End With

Set intMailConfig = New CDO.Configuration
Set Flds = intMailConfig.Fields
With Flds
  .Item(cdoSendUsingMethod) = cdoSendUsingPort
  .Item(cdoSMTPServer) = (NTS4.0/Exchange Machine)
  .Item(cdoSMTPConnectionTimeout) = 30
  .Item(cdoSMTPServerPort) = 25
  .Item(cdoSMTPAuthenticate) = cdoAnonymous
  .Update
End With

' Send an external message.

Set extMail = New CDO.Message
With extMail
  Set .Configuration = extMailConfig
      .bcc = bcc
      .To = externaladdress@externalserver.com
      .From = mailfrom
      .Subject = "test"
      .TextBody = "This is a test."
      .Send
End With

' send a local message.

Set intMail = New CDO.Message
With intMail
  Set .Configuration = intMailConfig
      .bcc = bcc
      .To = localaddress@myserver.com
      .From = mailfrom
      .Subject = "test"
      .TextBody = "This is a test."
      .Send
End With

---------------------------------------------------------
0
Comment
Question by:barryfandango
  • 5
  • 3
9 Comments
 
LVL 3

Accepted Solution

by:
MCummings111400 earned 385 total points
Comment Utility
From what I can tell, your problem is not in your code, but actually in your configuration of the IIS SMTP service. You can have the SMTP Service send mail externally (default) and configure it to deliver mail to your exchange server for all mail belonging to a particular domain (mycompany.com) You can then have your code simply reference the IIS SMTP Service and send all emails to it.

To set up the Exhcnage domain on the Win2K machine, use the IIS MMC to create a new SMTP Domain (Virtual Server)

0
 
LVL 3

Author Comment

by:barryfandango
Comment Utility
MCummings, this sounds like what I'm looking for - can you elaborate?
0
 
LVL 3

Author Comment

by:barryfandango
Comment Utility
MCummings,

I added a remote domain to the SMTP server on the win2k machine called myserver.com and set it to "forward all mail to the smart host :" to the IP of the exchange server.  It works - the mail sent to my local address arrived.  50% done - the external mail is still not delivering.
0
 
LVL 3

Expert Comment

by:MCummings111400
Comment Utility
How do you have the default SMTP Domain configured?

Check your SMTP Directories, is the mail going into you outgoing directory?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 3

Author Comment

by:barryfandango
Comment Utility
The messages are appearing in the "Queue" directory as EML files.  I receive delay notifications from the server about them, instructing me not to re-send.  Eventually i recieve a failure notification.  At that point i believe the messages are turned into BDP, BAD and BDR files and moved into the "Badmail" directory.
0
 
LVL 3

Author Comment

by:barryfandango
Comment Utility
As for the configuration of the domain, there doesn't appear to be very much configuration to do...  Opening the Properties of the local domain brings up a window with one option, about the location of the drop directory.  As for the configuration of the SMTP server itself:

General:
  IP Address : all unassigned, TCP Port 25

Access:
  Authentication : Set to Anonymous only
  Secure Communication : do not require a secure channel,
    no certificate installed.
  Connection Control : allow all
  Relay Restrictions : allow all

Messages:
  No limits set.  Non-delivery reports go to my address (a local one.)

Delivery:
  Outbound Security : Anonymous Access
  Expirations / timeouts etc set to default

LDAP : disabled




0
 
LVL 3

Expert Comment

by:MCummings111400
Comment Utility
Ok, 2 more questions:

1) What reason (if any) is given for the message being returned?

2) Can you (from the SMTP server) resolve the SMTP domains of the recipients you are trying to send to? (Ping, nslookup, etc...)
0
 
LVL 3

Author Comment

by:barryfandango
Comment Utility
Here is the mail that gets returned to me:
--------------------------
This is an automatically generated Delivery Status Notification.

Unable to deliver message to the following recipients, due to being unable to connect successfully to the destination mail server.

       xxx@hotmail.com
---------------------------

Extra info : if i open the "Computer Management -> Event Viewer -> System"  there are a pile of warning items from SMPTSVC, event type 4000, with the message  "Message delivery to the remote domain 'coair.com' failed for the following reason: %2 "  (Not very helpful.)

Using nslookup i am able to resolve the domains of various servers that i am trying to mail to.

Stranger and stranger : last night my co-worker installed some hotfixes on the SMTP server.  This morning i discovered that the SMTP server has changed to its previous state - it would send mail externally but not internally.  Then i rebooted it, and now both work.  So the problem is fixed, though i'm jittery since it broke for no apparent reason and now has fixed itself just as mysteriously.  Thanks for your help MCummings, you earned the points.

For future reference to any knowledge seekers - the hotfixes installed on the server were as follows :

Windows 2000 Hotfix Q313450
Windows 2000 Hotfix Q320206
Windows 2000 Hotfix Q314147
Windows 2000 Hotfix Q300845
Windows 2000 Hotfix Q313829
Windows 2000 Hotfix Q319733
Windows 2000 Hotfix Q311967
Windows 2000 Hotfix Q313582
0
 

Expert Comment

by:SamW
Comment Utility
Guys,

Have you checked to see that the computer you are working from is allowed to relay messages through the SMTP server you are using.

I have a web app that is doing a similar thing and was only able to get messages internally until I went to the mail server (exchange 2000 sp3) and went to "smtp virtual server" >> "properties" >> "access" >> "relay" and granted relay permission to the server that my web-app was on.  once I did that the messages started getting through.

This is probably diabled so external people don't connect to the smtp server and broadcast spam messages.

Anyway, it worked for me.  Hope it works for y'all.

Cheers from Austin.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now