programatically sending email

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Right guys.

(I would like a solution to this in VB6 as this is what our needy app is
written in, but any solutions that involve .NET would be much appreciated
likewise as I could instantiate them, otherwise please forgive the
crossposting.)

I'm sure I've seen posts here before criticising the practice of automating
outlook for the purpose of programatically sending email, on the grounds that
it's naff. Well now we're really landed in it, it's more than naff. The IT
department have applied some security patch, and it means that a guy in our
department now has to sit there for about 10 minutes constantly clicking
"yes" to the message box that pops up saying "an external program is trying
to use outlook to send email, do you want to allow this?, blah blah blah".
So I desparately NEED to find a way of sending email without using outlook,
and I haven't got the foggiest! I've heard of something called "MIME" - is
this a load of API functions I need to be using?
One other thing - the configuration. It's dead easy to set up outlook in our
network - when loading the profile for the first time, you just tell it the
name of the exchange server to connect to (which we don't have control over)
and it picks it up. Can MIME (if that's the technology I need to be using)
connect to an exchange server?

I'm sure I could understand it once I knew the general structure, so any
links to the basics would be much appreciated, aswell as people's experience
with common pitfalls. No third party controls if possible, as our IT
department have to authorise things like that and they are mightily
suspicious of them.
But it would sure impress people if I could program our way out of this
stupid corner that IT have boxed us into, so any help is much appreciated!

Thanks
 
Bonj said:
So I desparately NEED to find a way of sending email
without using outlook, and I haven't got the foggiest!

Sending and receiving email
I've heard of something called "MIME" - is
this a load of API functions I need to be using?

MIME is used for encoding mail attachments, for example.
 
Bonj,

See inline:

I've heard of something called "MIME" - is
this a load of API functions I need to be using?

MIME is short for Multipurpose Internet Mail Extension (I believe). It
is a way of formatting content in messages, it's not a protocol for sending
them.
One other thing - the configuration. It's dead easy to set up outlook in
our
network - when loading the profile for the first time, you just tell it
the
name of the exchange server to connect to (which we don't have control
over)
and it picks it up. Can MIME (if that's the technology I need to be using)
connect to an exchange server?

If your exchange server supports the IMAP or POP3 protocols, I would
suggest looking at the Indy Project:

http://www.indyproject.org

It has a number of classes that you can use to send/receive mail. The
thing is, it won't connect to Exchange directly, so you will have to connect
through the POP3 or IMAP connector.

Hope this helps.
 
Bonj said:
Right guys.

(I would like a solution to this in VB6 as this is what our needy app is
written in, but any solutions that involve .NET would be much appreciated
likewise as I could instantiate them, otherwise please forgive the
crossposting.)

I'm sure I've seen posts here before criticising the practice of automating
outlook for the purpose of programatically sending email, on the grounds that
it's naff. Well now we're really landed in it, it's more than naff. The IT
department have applied some security patch, and it means that a guy in our
department now has to sit there for about 10 minutes constantly clicking
"yes" to the message box that pops up saying "an external program is trying
to use outlook to send email, do you want to allow this?, blah blah blah".
So I desparately NEED to find a way of sending email without using outlook,
and I haven't got the foggiest! I've heard of something called "MIME" - is
this a load of API functions I need to be using?
One other thing - the configuration. It's dead easy to set up outlook in our
network - when loading the profile for the first time, you just tell it the
name of the exchange server to connect to (which we don't have control over)
and it picks it up. Can MIME (if that's the technology I need to be using)
connect to an exchange server?

I'm sure I could understand it once I knew the general structure, so any
links to the basics would be much appreciated, aswell as people's experience
with common pitfalls. No third party controls if possible, as our IT
department have to authorise things like that and they are mightily
suspicious of them.
But it would sure impress people if I could program our way out of this
stupid corner that IT have boxed us into, so any help is much appreciated!

Thanks

I would ask the IT department how to deal with the problem since THEY are
causing it and preventing YOU from doing your job.
Why should you (and your department) have to spent time (and hence money)
because another department is imposing it's own rules.
The IT department is suppose to help its users, not hinder them!!

John..
 
Nicholas said:
It has a number of classes that you can use to send/receive mail. The
thing is, it won't connect to Exchange directly, so you will have to connect
through the POP3 or IMAP connector.


POP3 and IMAP are protocols for receiving mail,
I don't think they'd be much help with sending.



Bob
--
 
Nospam said:
I would ask the IT department how to deal with the problem since THEY are
causing it and preventing YOU from doing your job.
Why should you (and your department) have to spent time (and hence money)
because another department is imposing it's own rules.
The IT department is suppose to help its users, not hinder them!!

John..

The box that is a problem is a "feature" Microsoft added to later versions
of Outlook 2000 security patches. This anonying feature was implimented to
prevent script based virii from mass mailing.

While I can say that the box is anonying, I'd much rather deal with it then
leave a system open to virus attacks since it's not properly maintained.

Here is the response I sent to Terry Holland about this very subject earlier
today:

The first option that comes to mind is for you to use CDO to directly access
Outlook and avoid the nice interface you are using. Note that CDO is a pain
to code in. The another option is to use a program called Outlook
Redemption (http://www.dimastr.com/redemption/), using this will allow you
to use the code you have already written with very few changes. I used it a
few years ago and it wasn't too expensive, had a lenient license, and the
creator was very helpful and quick at responding to questions. The final
option is to access the popup box from VB and sendkey commands to it to
automatically close it.

Outlook Redemption is really the best solution in my eyes; however, you
could use SendKeys. It's messing and definately not proper coding in my
eyes, but it will get the job none without a 3rd party program.
 
Paul,
The first option that comes to mind is for you to use CDO to directly
access
Outlook and avoid the nice interface you are using. Note that CDO is a
pain
to code in. The another option is to use a program called Outlook
Redemption (http://www.dimastr.com/redemption/), using this will allow you
Note: CDO 1.2.1 that ships with current versions of Outlook has the same
security feature.

Hope this helps
Jay
 
It also supports SMTP, I think that was what I was going for.

Thanks for the correction.
 
Thanks a lot all...I'll check out some of the links and see if anything can
be done.
I think I meant "MAPI", not "MIME" - picked the wrong acronym, sorry! I'm
not actually at all interested in encoding any mail...
 
Hi
Thanks for all the replies, I managed to get it to work using CDO, via the
System.Web.Mail namespace, however it will only send a mail from a machine
that has got IIS SMTP server running on it, and if I stop it, then it still
works - but the mail only arrives when the SMTP server is restarted. Using
Smtp.SmtpServer property (Insert or just plain setting it) doesn't seem to
affect the out come at all.
Does anybody know how I can get it to use a particular exchange server (that
we don't have control over) whether IIS is installed locally or not?
 
Here's some code I used once upon a time (in VB5):

MAPISession1.NewSession = False
MAPISession1.LogonUI = False
MAPISession1.DownLoadMail = False
MAPISession1.UserName = vbNullString
MAPISession1.SignOn

MAPIMessages1.SessionID = MAPISession1.SessionID
MAPIMessages1.MsgIndex = -1
MAPIMessages1.Compose
MAPIMessages1.RecipDisplayName = eMailAddress$
MAPIMessages1.MsgSubject = "Message From My Program!"

X$ = "Testing, testing, 1 , 2, 3" & vbCrLf
X$ = X$ & "This is line #2" & vbCrLf
X$ = X$ & "Etc." & vbCrLf

MAPIMessages1.MsgNoteText = X$
MAPIMessages1.Send False

DoEvents

MAPISession1.SignOff
 
Whoops... :(

I just tried this (using the program I took the code from) and was
surprised to see that the warning you're trying to avoid popped up. I
had never seen this before (its been several years since I used this).

I guess this code won't help you at all.

Sorry.
 
Oh, really! - does it!

That's good to know - I'll not go down that road then

I'm really trying to get it to work by using CDO without having IIS
installed on the machine, but it doesn't matter if it does because a lot of
the machines have got IIS installed.

Cheers anyway
 
Bonj said:
Hi
Thanks for all the replies, I managed to get it to work using CDO, via the
System.Web.Mail namespace, however it will only send a mail from a machine
that has got IIS SMTP server running on it, and if I stop it, then it still
works - but the mail only arrives when the SMTP server is restarted. Using
Smtp.SmtpServer property (Insert or just plain setting it) doesn't seem to
affect the out come at all.
Does anybody know how I can get it to use a particular exchange server (that
we don't have control over) whether IIS is installed locally or not?



:

I was hesitant to offer a reply as we resolved this problem somewhat
differently. We had a client that was running a suite of applications that
utilized email services. They broke for very much the reasons you listed. We
punted and implemented a COM+ messaging service. Notifications to send an
email were then sent to a central service which had its own email account.

hth
-ralph
 
Ralph (& Bonj),
I was at a client earlier this year that did the same thing. They set up a
Web Service that would send an email, which in many ways makes sense. As you
do not need to open up or manage allot of machines with the CDONTS or CDOSYS
on them. You can simply manage a single machine with CDOSYS on it. Allowing
better control in the fight against viruses, worms & other things
potentially infecting the networks...

They also had a special Queue they could use for Message Queuing
applications (MQ Series, MSMQ)...

Hope this helps
Jay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top