Solved

Script an email to send on a daily basis from outlook 2003

Posted on 2004-10-04
4
353 Views
Last Modified: 2008-02-01
I've read through the posts on this from various other areas of EE, and I still have a few questions.  Here is what I am trying to do:

I have a file that is created on my C drive at 5:30 AM everyday.  I need to email this file as an attachement on a daily basis to 2 recipients.  I would like to schedule the email to be sent at 6:30 AM.

I built a macro in Outlook that does what I need to do, see below, however, I don't know how to schedule it to run, and then I don't know how to get around the outlook security warning that comes up about being sent on my behalf.  I did install "click yes", but, if my machine is locked, as it usually is at 6:30 AM, you know that click yes will not work.

I was hoping to use WSH, so that this may not be outlook dependant, I did find vbsendmail, but it's a bit beyond what I know how to do in VB.

Thanks,
Scott
Here's my code:

Sub scanxfer()
Dim objOutlook
Dim objEmail

Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)

With objEmail
    .To = "swarm@gwn.com"
    .Subject = "test"
    .Body = "hi guys"
    .Attachments.Add "c:\scanxfer.txt", olByValue
    .Send
End With

Set objOutlook = Nothing

End Sub
0
Comment
Question by:scottman29
  • 2
  • 2
4 Comments
 
LVL 32

Expert Comment

by:Erick37
ID: 12218429
You can run your script as a scheduled task in Windows.

Control Panel->Scheduled Tasks->File->New...

Hope it helps!
0
 
LVL 5

Author Comment

by:scottman29
ID: 12218465
do you mean put that script in a .bat file and then schedule it?  will it get around the outlook security that way as well?
0
 
LVL 32

Accepted Solution

by:
Erick37 earned 500 total points
ID: 12218717
Here is an article from MS using CDO to send mail via a remote SMTP server:

How To Send HTML Formatted Mail Using CDO for Windows 2000 and a Remote SMTP Service
http://support.microsoft.com/default.aspx?scid=kb;en-us;286431

The script is saved as a VBScript (vbs) file.
0
 
LVL 5

Author Comment

by:scottman29
ID: 12239364
looks like what I want, thanks!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

821 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