Solved

Scheduling outlook macro to run weekly

Posted on 2010-09-01
2
1,572 Views
Last Modified: 2012-05-10
Hi All,

I'm look for the most efficient way to send a file on your hardrive as an attachement via email.
The closes I've got so far is an Outlook macro
Sub sl()
    Dim olApp As Outlook.Application
    Dim objMail As Outlook.MailItem
    Set olApp = Outlook.Application
    Set objMail = olApp.CreateItem(olMailItem)
    objMail.BodyFormat = olFormatPlain
    objMail.Subject = "Hi buddy"
    objMail.Body = "Whats up" + Chr(13) + Chr(10) + "Greg"
    objMail.To = "putin@email.com"
    objMail.Attachments.Add ("C:\TEMP\test.csv")
    objMail.Send
End Sub


I don't know how to schedule this macro to run Monday morn for example every monday.

Any help would be greatly appreciated (also if you know of another way to automatical email a file that would be helpful as well)

Thanks,
Paul
0
Comment
Question by:B_rider
2 Comments
 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 500 total points
ID: 33581395
Create a task in outlook, that recurs for example every Monday.  Now in the VBA create the following code to run the macro:

Chris

To Create a macro:
------------------

Alt + F11 to open the macro editor

  For Applicationevent handlers:
     In the project tree select as appropriate:
      OUTLOOK      : thisOutlookSession
     In the workpane select as appropriate:
      OUTLOOK      : Application
     In the workpane select the required 'event', (i.e. 'open').
     Either
        Insert the required code from the supplied sub into the selected subroutine.
     Or
        Replace the template inserted by the VBE with the sub as supplied

           
  For User Code:
     Insert | Module to insert a code module into the project
     In the project tree select the module.
     Insert the required macro(s) into the selected module, ('Module1' or similar)

Close the Visual Basic Editor.

Check Security as appropriate:
------------------------------

In the application select Tools | Macro | Security
2003 and Earlier : Select Medium
2007 : Outlook - Warnings for all Macros
     : Others - Enable a trusted location and inhibit macros otherwise so do both!
      : Disable Macros
            Office Button, (top left of the screen)
            Options
            Trust Centre
            Trust Centre Settings
            MAcro Settings
            Disable All MAcros with warnings
      : Enable Trusted Locations
            Office Button, (top left of the screen)
            Options
            Trust Centre
            Trust Centre Settings
            Trusted Locations
            Add a preferred location
            ENSURE YOUR FILE IS IN A TRUSTED LOCATION
            Re-open to ensure it is recognised if the above has been changed
            
Select OK
Option Explicit



Private Sub Application_Reminder(ByVal Item As Object)

    sl

End Sub



Sub sl()

    Dim olApp As Outlook.Application

    Dim objMail As Outlook.MailItem

    Set olApp = Outlook.Application

    Set objMail = olApp.CreateItem(olMailItem)

    objMail.BodyFormat = olFormatPlain

    objMail.Subject = "Hi buddy"

    objMail.Body = "Whats up" + Chr(13) + Chr(10) + "Greg"

    objMail.To = "putin@email.com"

    objMail.Attachments.Add ("C:\TEMP\test.csv")

    objMail.Send

End Sub

Open in new window

0
 

Author Comment

by:B_rider
ID: 33694582
Hi this worked great thanks!
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Lotus Notes – formerly IBM Notes – is an email client application, while IBM Domino (earlier Lotus Domino) is an email server. The client possesses a set of features that are even more advanced as compared to that of Outlook. Likewise, IBM Domino is…
Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
In this video we show how to create an email address policy in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Mail Flow…

932 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now