Solved

Scheduling outlook macro to run weekly

Posted on 2010-09-01
2
1,566 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Are you unable to connect or configure Hotmail email account in Microsoft Outlook 2010, 2007? Or Outlook.com emails are not downloading to Outlook? Lets’ see the problem and resolve Outlook Connector error syncing folder hierarchy (0x8004102A).
In this video we show how to create a Distribution Group 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 Recipients >>…
In this video we show how to create a mailbox database 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 Servers >> Data…

747 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

11 Experts available now in Live!

Get 1:1 Help Now