Autosend Email With Attachments

  • Thread starter Thread starter akivabrown
  • Start date Start date
A

akivabrown

Hey guys i'm sure this has been posted but i just couldn't find it. I'm
new to VB but was told it's the easiest way to do what i need. I
usually program in java and several others but here goes. I need a
program to auto send an email once a night with an attachment. The
attachment would be in the form xx_xxxx_27062006.csv where 27062006 is
the date 27/06/2006. I would need the VB program to pull data from the
system clock and add the date as a variable in the file_path string.
The second part i need is the automated sending of the email with the
attachment. This would be the hardest part of the program (i would
think, but hey what do i know). The third part i would do is to auto
run this program at about 12 midnight, so i would just put it into
windows task scheduler. Any ideas to point me in the right direction or
any reading material would be appreciated.

Thanks,
Kevin
 
I know that you know a hell of alot more than me, but i just sent
myself an email via the script. It's a basic code to send out an email
in a .vbs which was set to run via windows task scheduler.

The only problem i have now is concatenating the date to a string for
use inside the find file. I need it in format 28062006 for "ddmmyyyy"
and format(now, "ddmmyyyy") and now.toString("ddmmyyyy") both don't
work. Any suggestions?
 
I'm sure you got it to work using shellexecute or something with the mailto
command, but it still doesn't change the fact that you cannot use the Outlook
Object Model inside an application that's run via the Task Scheduler. The
code you used did not use any Outlook objects (eg. Outlook.Application,
Outlook.MailItem, etc.), but you'd need to use the OOM if you wanted to
insert attachments.

Try Format(Date(), "ddmmyyyy").
 
=?Utf-8?B?RXJpYyBMZWdhdWx0IFtNVlAgLSBPdXRsb29rXQ==?=
it still doesn't change the fact that you cannot
use the Outlook Object Model inside an application that's run via the
Task Scheduler.

Strictly speaking, you _can_ run it, it just most likely won't work
properly. The KB article quotes four problems, which you can work around
by:

1. leaving the user that's meant to be running the Outlook code always
logged in
2. making sure the logged-in user isn't running Outlook when the
scheduled stuff is meant to fire off.
3. uh.. being lucky? heh. If it's working for the OP, then presumably
the particular mapi spooler interactions in question are going okay
4. writing code so it doesn't pop up any dialogs.

(wow, http://support.microsoft.com/kb/259971/ has an ingenious, but
also very ghastly hack to get around that last problem)

Point 3 is the obvious killer, and 1 and 2 basically clobber any sort
of normal run-as-a-service stuff, but in very particular, carefully
controlled, environments, it might be possible to get things to work.

It's sort of like coding with CDO1.21/ExMAPI and .Net, except the other
way around -- OOM from a service probably won't work, but occasionally
may mysteriously succeed; CDO1.21 will probably work okay from .Net, but
occasionally will mysteriously fail.

In general, though, it's much better to use CDO1.21/one of the other
CDOs/ExMAPI.

-- dan
 
I don't even think that hack for #4 will work on the most recent versions.

I'd use CDO for Windows to do this if it were my project.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Sue Mosher said:
I don't even think that hack for #4 will work on the most recent
versions.

Yeah, I'll admit it was Outlook 97 when I last tried this sort of thing,
and stuff was generally a lot more lax back in those days.. :)

-- dan
 
Back
Top