Solved

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

Posted on 2004-10-04
4
349 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Link a textbox in excel to a cell with more than 255 characters. 5 89
Access 2016 VB code 9 115
Excel object stays open 19 76
Updates not working for MS Windows 7 12 166
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

773 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