Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming VBA / June 2006

Tip: Looking for answers? Try searching our database.

Autosend Email With Attachments

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
akivabrown@gmail.com - 28 Jun 2006 16:03 GMT
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
akivabrown@gmail.com - 28 Jun 2006 18:20 GMT
I actually got the email aspect running now all i need is the date addin
Eric Legault [MVP - Outlook] - 28 Jun 2006 18:26 GMT
You're out of luck - you cannot automate the Outlook Object Model from a
Scheduled Task:

The Outlook Object Model is unsuitable to run in a Windows service:
http://support.microsoft.com/default.aspx?scid=kb;en-us;237913

You'd need to use CDO instead.

Signature

Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/

> 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
[quoted text clipped - 12 lines]
> Thanks,
> Kevin
akivabrown@gmail.com - 28 Jun 2006 19:23 GMT
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?

Eric wrote:

> You're out of luck - you cannot automate the Outlook Object Model from a
> Scheduled Task:
[quoted text clipped - 26 lines]
> > Thanks,
> > Kevin
Eric Legault [MVP - Outlook] - 28 Jun 2006 20:08 GMT
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").

Signature

Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/

> 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
[quoted text clipped - 37 lines]
> > > Thanks,
> > > Kevin
Dan Mitchell - 28 Jun 2006 22:36 GMT
=?Utf-8?B?RXJpYyBMZWdhdWx0IFtNVlAgLSBPdXRsb29rXQ==?=
<elegaultZZZ@REMOVEZZZmvps.org> wrote in
news:B83324B6-D6E0-474C-A993-3314F6E23C73@microsoft.com:
> 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


Sue Mosher [MVP-Outlook] - 28 Jun 2006 22:40 GMT
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.

Signature

Sue Mosher, Outlook MVP
  Author of Configuring Microsoft Outlook 2003
    http://www.turtleflock.com/olconfig/index.htm
  and Microsoft Outlook Programming - Jumpstart for
    Administrators, Power Users, and Developers
    http://www.outlookcode.com/jumpstart.aspx
 

> =?Utf-8?B?RXJpYyBMZWdhdWx0IFtNVlAgLSBPdXRsb29rXQ==?=
> <elegaultZZZ@REMOVEZZZmvps.org> wrote in
[quoted text clipped - 31 lines]
>
> -- dan
Dan Mitchell - 29 Jun 2006 00:48 GMT
> 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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.