Link to home
Start Free TrialLog in
Avatar of mjasic
mjasic

asked on

Send email from Access - bypass Outlook prompt

Hi,
Is there any way to send an email from Access and bypass the Outlook XP prompt "There is a program trying to send automatically an e-mail on your behalf..." (or something like this, because I'm using the French Win2K and Office so I can't see the english message) and wait for 5 seconds and click on Yes? I have to automate the sending and nobody wants to click one hundred times on Yes.
I tried with SendObject, I tried with CDO too, with Outlook.Application. Nada. Always the same unnecessary question. Is there any way to play with SMTP from code?

Thanks,

Michel

Avatar of shanesuebsahakarn
shanesuebsahakarn
Flag of United Kingdom of Great Britain and Northern Ireland image

Have a look here:
http://www.granite.ab.ca/access/email.htm

Look in the box titled:
Outlook Security Patch in Outlook 98, 2000 SP-2 and Outlook 2002

This link:
http://www.microsoft.com/office/ork/xp/appndx/appa11.htm

should provide you with the tool you need to remove the message if you are using Exchange Server.
Avatar of Jim Dettman (EE MVE)
<<Is there any way to play with SMTP from code?>>

  The best setup for e-mail is to talk directly to a SMTP server.   You can buy a 3rd party control, or use something like BLAT.

  A .DLL is available for BLAT, so you can use it right in your code.  Do a web search for BLAT and you'll turn it up quick.

Jim.

Avatar of dotthei
dotthei

Jim:
Not trying to step on your toes, just a thought...

Windows comes canned with Telnet.
You have to Telnet (Xserver) on port 25

example

telnet iname.com 25
dotthei,

<<Jim:
Not trying to step on your toes, just a thought...>>

 Please not at all.  Always good to offer alternatives....
Never even thought of using Telnet to send mail<g>.

Jim.
I have not used Telnet to send mail (although I do know it is valid and functional and old school)

The only text I have on it's usage is for sending anonymous email

ALSO PLEASE NOTE
mjasic:

Outlook has an option
Warn Me When Another Application Is Trying To Send Mail.
Have you turned this option off?
Avatar of mjasic

ASKER

dotthei,

1) Where can I find this option. It seems it doesn't exist in Outlook XP. I saw it in Outlook Express (I think). I can't modify any of my security options.

2) Should I use Telnet from Shell?

Thanks,

Michel
Avatar of mjasic

ASKER

dotthei,

1) Where can I find this option. It seems it doesn't exist in Outlook XP. I saw it in Outlook Express (I think). I can't modify any of my security options.

2) Should I use Telnet from Shell?

Thanks,

Michel
Should I use Telnet from Shell?
It is an option.

Assumption: You are familiar with shell
note that Shane might know a better way to call telnet

Rudimentary How To
This is extracted directly from How To Send Anonymous email
just in case you need it

Go to Start, then Run...
You have to Telnet (Xserver) on port 25

Well, (In this Xserver) you have to put the name of a server without the ( ) of course...
Put in iname.com in (Xserver) because it always work it is a server with many bugs in it.
(25) mail port.

So now we are like this.

telnet iname.com 25

and then you hit enter
Then When you have telnet open put the following like it is written

helo

and the machine will reply with smth.

Notice for newbies: If you do not see what you are writing go to Terminal's menu (in telnet) then to Preferences and in the Terminal Options you tick all opctions available and in the emulation menu that's the following one you have to tick the second option.
Now you will se what you are writing.

then you put:

mail from:<whoeveryouwant@whetheveryouwant.whetever.whatever> and so on...
If you make an error start all over again

Example:
mail from:<askbill@microsoft.com.net>

You hit enter and then you put:

rcpt to:<lamer@lamer'sworld.com>
This one has to be an existance address as you are mailing anonymously to him.

Then you hit enter
And you type
Data
and hit enter once more

Then you write

Subject:whetever

And you hit enter

you write your mail

hit enter again (boring)

you put a simple:
.

Yes you don't see it its the little point!
and hit enter
Finally you write
quit
hit enter one more time
and it's done
Avatar of mjasic

ASKER

It seems too complicated to be automated.
In fact, the application is for our Customers Service and they have a list of 6000 names to send to. As our firewall accepts up to 50 names/message, actually it is divided in 150 groups of about 50 names. It is sure that I can't apply Telnet in my loops and counts.

Positive, I find the option "to prompt or not to prompt" (it's not Shakespeare ;) in Outlook Express, but not in Outlook XP.

It is unbelievable what a monster M$ has built with Outlook and its security because of all the security wholes it had in the past :(
You could run telnet directly using Winsock but it isn't trivial. Stick with what works :)
mjasic, look at the links I gave you to remove the prompts from Outlook 2002.
Once again, I would avoid the use of any e-mail client.  In using one, you depending on the client configuration, which may change depending on where the software is installed.

  By talking to a SMTP server directly, you can avoid all that.  Check out BLAT.  It's simple and easy to use and works well.  If you don't want to go that route, I do have a VBA solution I can send you as well.

Jim.
Disclaimer: I haven't yet arrived at this part of my current project, so I can't say I've actually tried this.

I have to recommend MAPI.  There are several reasons.

Why not to use telnet:
 - It's hard to control programatically (unless using Expect on unix)
 - You're on your own to figure out which mail server to talk to.
 - The user may be behind a firewall and not be able only be able to connect to their corporate SMTP server.
 - The SMTP server may require authentication.
 - The "From:" line must be guessed.

Why you shouldn't talk to SMTP servers directly:
 - If the user is behind a firewall (corporate or and ISP) they may not be able to connect to all SMTP servers, only their local one.
 - You have to know which email client on their machine to read the "From:" line from.

The safest way is to use the user's pre-configured mail program.  MAPI is designed to let you send an email without having to know any configuration details.  It's also designed to work with whatever mail program they may have installed/configured.  You're saved from having to figure out if they're behind a firewall, which mail server they use, if it requires authentication and what their "From:" line should read.

I'd start with the link that Shane posted in the first reply and read the section on MAPI.
The amigo:

<<The safest way is to use the user's pre-configured mail program.  MAPI is designed to let you send an email without having to know any configuration details.  It's also designed to work with whatever mail program they may have installed/configured.  You're saved from having to figure out if they're behind a firewall, which mail server they use, if it requires authentication and what their "From:" line should read.>>

 I would disagree.  MAPI may not even be installed on the client.  Relying on MAPI is just as bad as going through a mail client (which is just on top of MAPI of VIM anyway).  

 As far as the "from" line, there is no address resolution taking place as this is outgoing mail.  I have both a hardware and software firewall and have no problems talking to my ISP's SMTP server.  How do you think MAPI gets to it?

Jim.
I had at least one situation where the client PCs could not access the corporate SMTP server. For example, if you are using Exchange, the Exchange server has access to the SMTP server but the client PCs don't, and the corporate IT department flat out refused to provide an SMTP service.
Personal firewalls aren't so much a problem.  Corporate firewalls are.  Many corporations do not use NAT and choose to allow traffic to only reach the internet via proxy services (limiting to HTTP, telnet and ftp).  Sometimes even only after authentication to the proxy server.

If a user is behind such a corporate firewall, they cannot connect to any SMTP server outside of their organization.  Their pre-configured mail client (whichever it may be) will know which internal SMTP server to send mail through.

The issue of the From: line is that if you're sending mail directly to an SMTP servere, who do you tell the server the email is from?  You can use CurrentUser() to get their name, but this doesn't tell you thier email address.  Granted, this certainly doesn't hinder the process of sending an email but it does make it more difficult for the recipient as they can't simply click reply to write back.

Is MAPI not part of Windows in all Win95 and newer systems?  Maybe not, I really don't know, but I thought it was.
Shanesuebsahakarn/Amigo,

<<I had at least one situation where the client PCs could not access the corporate SMTP server. For example, if you are using Exchange, the Exchange server has access to the SMTP server but the client PCs don't, and the corporate IT department flat out refused to provide an SMTP service.>>

  There are situations like that.  Guess I've been lucky so far.

<<Personal firewalls aren't so much a problem.  Corporate firewalls are.  Many corporations do not use NAT and choose to allow traffic to only reach the internet via proxy services (limiting to HTTP, telnet and ftp).  Sometimes even only after authentication to the proxy server.
>>

  That's not a problem as you then use the proxy address rather then the address of the SMTP server or they provide an internal SMTP server.  So far, this has not been an issue for me.

<<If a user is behind such a corporate firewall, they cannot connect to any SMTP server outside of their organization.  Their pre-configured mail client (whichever it may be) will know which internal SMTP server to send mail through.>>

  You do direct the mail to the correct server, so I don't understand why you think this is a problem.  The software you put in place, be it BLAT or VBA code, replaces the functionality of the mail client.  The end result though is better control over the process and you don't have to determine and code to a specific client.

<<The issue of the From: line is that if you're sending mail directly to an SMTP servere, who do you tell the server the email is from?  You can use CurrentUser() to get their name, but this doesn't tell you thier email address.  Granted, this certainly doesn't hinder the process of sending an email but it does make it more difficult for the recipient as they can't simply click reply to write back.>>

  You make it whatever you want, just like a mail client does.

<<Is MAPI not part of Windows in all Win95 and newer systems?  Maybe not, I really don't know, but I thought it was. >>

  No, MAPI may or may not be installed on a Win9x machine.  VIM can be installed in it's place.  I'm not sure about Win NT and up.

  What I guess it all boils down to is past experience.  My problem has always been the client.  Never sure if it's going to be Outlook 2000, 97, etc or some other 3rd party client (ie. Lotus Notes).  If the client changes, the software fails.  And then there is the issue of MAPI being installed or not.  Plus the fact that the software now depends on a whole additional layer of software (can't tell you how many times I've gotten nailed because someone's Notes ID file got messed up).  Anytime I've had to work through clients, it's always a hassel.

  By talking directly to a server, I bypass all those problems.  In a nutshell, the only thing the mail client does is present an interface for getting a message and then formatting it and sending to an SMTP server. I replace that with my own "mail client". Whatever security issues you talk about are the same ones that would be faced by any other mail client.  There is no difference.

Michel:

  In answer to your question:

"Is there any way to play with SMTP from code?"

  I do have a VBA Send Mail example that I can send you.


Jim.
Avatar of mjasic

ASKER

OK my situation is as follows:

All the computers have Win2K Pro. The one that should send a message is the same. All the machines have Office XP complete and there is a corporate firewall. I can't even get my mail from Hotmail.

We changed the Exchange server parameters as in "Customizing the Outlook Security Features Administrative Package" by M$, added a registry key on my test computer and there is still the Outlook prompt. Maybe we missed something.


I suppose I should play directly with server parameters from my code, but I don't know how.

To JDettman: John, does your code play directly with SMTP server? Thare is no problem with "From" because there is only one address. I can even hardcode it. It never changes.


This is one of the procedures I use:
 '-------------------------------------------------------
Public Function OutlookMail(ByVal EmailID As String, ByVal Subj As String, ByVal Body As String) As String

       Dim oApp As Outlook.Application
       Dim oMail As Outlook.MailItem

       On Error GoTo ErrHandler

       Set oApp = New Outlook.Application
       Set oMail = oApp.CreateItem(olMailItem)

       oMail.To = EmailID
       oMail.Subject = Subj
       oMail.Body = Body
       oMail.Send

       Set oMail = Nothing
       Set oApp = Nothing

        OutlookMail = "True"

        Exit Function

ErrHandler:
       OutlookMail = Err.Description
End Function

 '-------------------------------------------------------


This is the another one that I tested:

 '-------------------------------------------------------
Public Function sendmail(Recip As String, Subject As String, strText As String)
   Dim osession As MAPI.Session
   Dim omessage As message
   Dim oRecip As Recipient
   
   Set osession = CreateObject("MAPI.Session")
   osession.Logon
   Set omessage = osession.Outbox.Messages.Add
   omessage.Subject = Subject
   Set oRecip = omessage.Recipients.Add(Recip)
   oRecip.Resolve
   omessage.Text = strText
   
   omessage.Send , False
   osession.Logoff
End Function
 '-------------------------------------------------------

I tried with CDO, but can't avoid the prompt.

Michel
Michel, you mention that you're using Outlook in a corporate environment.  I'd guess this also means that the servers are running Exchange.  Is this the case?  Outlook sends mail to Exchange servers via a proprietary protocol (not SMTP).  Exchange servers are capable of recieving mail from SMTP clients (I personally use Mozilla to send mail to my corporate Exchange server via SMTP), but if Outlook is enforced as the mail client to be used, the Exchange servers may have SMTP disabled.

A quick test is to open Outlook, and under Tools -> Services, one of those will tell you what your Exchange server is (sorry I can't be more specific, I don't have Outlook on my PC).  Then try telnetting to that machine on port 25 and see if you can connect.

A MAPI solution will work either way, but talking to an SMTP server directly requires that the mail server be using SMTP.

Jim, with a proxy-based firewall, I'm guessing BLAT will fail (SMTP doesn't have any official support for proxying).  I'm also guessing BLAT uses DNS MX records to find the proper SMTP server, which fails beind a proxy-based firewall.  The alternative is to have the end user configure BLAT to connect to their own mail server.  In the office I'm in, the local servers require authentication to send SMTP mail which means more hassle for the end user.

Isn't MAPI what's used when you click on a mailto: link on a web page?  That way any browser works with any mail client (on Windows anyway), and for users who want saved copies of outgoing mail, their mail client can do so.
<<To JDettman: John, does your code play directly with SMTP server? Thare is no problem with "From" because there is only one address. I can even hardcode it. It never changes.>>

  Yes it does as does BLAT.

Jim.
BTW it is simple enough to test BLAT quickly and see if it works in your environment.  BLAT is a command line utility that lets you send an e-mail from a command prompt.  It also has a DLL that you can call from a program to send mail.

If that works (should take all of 10 minutes to check), then you can use that or the VBA code I have.  Either would work.

Jim.
BTW, here's a link to the BLAT start page:

http://www.interlog.com/~tcharron/blat.html

Jim.
<<Jim, with a proxy-based firewall, I'm guessing BLAT will fail (SMTP doesn't have any official support for proxying).>>

  No, because you point to the proxy, which then forwards to the SMTP server.

<<  I'm also guessing BLAT uses DNS MX records to find the proper SMTP server, which fails beind a proxy-based firewall.>>

  No, it can work on IP addresses as well as fully qualifed DNS names.  Again, if the the mail client can do it, so can BLAT.

<<  The alternative is to have the end user configure BLAT to connect to their own mail server.  In the office I'm in, the local servers require authentication to send SMTP mail which means more hassle for the end user.
>> 

 For authentication, you would need to supply a username and password, which can be specified as part of the command line.

Jim.

Avatar of mjasic

ASKER

To Jdettman:

Jim, I followed the link you gave me and found blat and a good example for Access with Blat that worked for the internal addresses (behind the firewall). Didn't recognized may home address. Probably I should supply the username and password. Wasn't in the example.

<<If that works (should take all of 10 minutes to check), then you can use that or the VBA code I have.Either would work.>>

Does your VBA code use Blat or any other external component?
Can you send it to me, please?
If my wife is not at home rigt now to pick it up and forward it to my office, I'll have to wait until tomorrow to test it. :)

Thanks,

Michel
Avatar of mjasic

ASKER

To be more clear: in "To" field, no external addresses were recognized(outside of the same domain).

Michel
"no external addresses were recognized(outside of the same domain)."

Can you ping an address outside your domain?  If it fails, does it at least get the IP address?  It would be quite common for a corporate environment to block this sort of thing.  BLAT is probably trying to use DNS to find and contact the mail server of the recipient.

When you run Outlook, it doesn't do that, it gives it to your local SMTP server which can forward it to your corporate mail gateways that can get the message out to the internet.  To get a tool like BLAT to work, you'd have to tell it: The From address, your local mailserver name, your username and password.  That's why I advocate using MAPI since it will use Outlook which is already configured.

Additionally, if your mailserver is moved or renamed, then Outlook will be automatically updated with the new info and you won't notice a change, but BLAT will quit working.

Jim, there is no such thing as an SMTP proxy.  The protocol doesn't support proxying.  You can pull it off using a telnet proxy, but then BLAT would need to know how to connect to a telnet proxy, what type of prompt to expect (they're all different), your username/password and the proxy would have to allow telnetting to port 25 on external servers.  As there's no good reason to allow doing so, it's quite reasonable for a corporation do restrict which ports you can telnet to (mine does).
ASKER CERTIFIED SOLUTION
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mjasic

ASKER

Although I didn't test Jim's code (I send him my email address a couple of minutes ago), he already helped me a lot to find out where the problem was. Thanks to him, I found BLAT and tested it and, as Jim recommended, I asked for some permissions from my Net Admin (waiting for an answer).
He guided me through this delicate issue with some other guys, but really his solutions were the most clear and the most accurate.

Avatar of mjasic

ASKER

Thanks to all you guys too.

Michel
Michel,

 e-mail is on the way.  Also for anyone that's interested, here's the link to the VB code solution I posted:

http://www.freevbcode.com/ShowCode.Asp?ID=109

  Although written for VB, it works fine in Access.  I know quite a few people here on EE have used it with great sucess.

Jim.