+ Reply to Thread
Results 1 to 14 of 14

Automatically Send an Email with CDO at Specfic Date and Time

  1. #1
    Registered User
    Join Date
    03-04-2010
    Location
    South Florida
    MS-Off Ver
    Excel 2007
    Posts
    72

    Automatically Send an Email with CDO at Specfic Date and Time

    Hello,

    I got the code below from www.rondebruin.nl and it works great for sending an email to my gmail account (I've altered it slightly). Can someone show me what code I would need to add in order to set this up for a future date and time? Lets say, 9:00AM (EST) on 11/27/2011. And is it possible to automatically execute the macro without having Excel open or having my computer on as long as I had an internet connection that is always connected?

    Thank you!


    Please Login or Register  to view this content.

  2. #2
    Registered User
    Join Date
    03-04-2010
    Location
    South Florida
    MS-Off Ver
    Excel 2007
    Posts
    72

    Re: Automatically Send an Email with CDO at Specfic Date and Time

    Thanks to the person who adjusted the title to make it more accurate.
    Anyone have any ideas?

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Automatically Send an Email with CDO at Specfic Date and Time

    Hello Orangeworker,

    To have the macro run unassisted will require creating a Scheduled Task. This will open the workbook at the time and date you specify.

    Since your email doesn't rely on any information stored in the workbook, there may be another option. I am not sure about this option, as I have never tried it, but it may work. You might be able to create a VBScript file instead of using Excel.

    You would still need to have a Scheduled Task to run either option. In any case, your computer must be up and running and connected to internet before the email can be sent.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Registered User
    Join Date
    03-04-2010
    Location
    South Florida
    MS-Off Ver
    Excel 2007
    Posts
    72

    Re: Automatically Send an Email with CDO at Specfic Date and Time

    Hi Leith,

    Thanks for your response. I am looking into both of your answers. I will get right back once I read a little on both.

  5. #5
    Registered User
    Join Date
    03-04-2010
    Location
    South Florida
    MS-Off Ver
    Excel 2007
    Posts
    72

    Re: Automatically Send an Email with CDO at Specfic Date and Time

    Okay, I've decided to go with the "Scheduled Task" option first and am encountering this error:

    The new task has been created, but may not run because the account information could not be set.

    The specific error is:

    0x80070005: Access is denied

    Try using the Task page Browse button to locate the application.
    I have browsed to the correct path of the file. Do I need to save the Excel sheet with a different extension other than .xlsm ?

  6. #6
    Registered User
    Join Date
    03-04-2010
    Location
    South Florida
    MS-Off Ver
    Excel 2007
    Posts
    72

    Re: Automatically Send an Email with CDO at Specfic Date and Time

    I thought it might be password related cause I didn't have an administrator password. I've created one and am still encountering the same error.

  7. #7
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Automatically Send an Email with CDO at Specfic Date and Time

    Hello Orangeworker,

    You probably have already seen or visited this link about the scheduling a task in Windows 7 but I will post it for others.

    Schedule a Task to Run Automatically in Windows 7

  8. #8
    Registered User
    Join Date
    03-04-2010
    Location
    South Florida
    MS-Off Ver
    Excel 2007
    Posts
    72

    Re: Automatically Send an Email with CDO at Specfic Date and Time

    Leith,

    I'm still getting the error below, any thoughts as to why?

    An error occurred while attempting to set account information.

    The specific error is:

    0x80070005: Access is denied.

    You do not have permission to perform the requested operation.
    When it asks for a password, is this password something that was previously created, or
    is it asking me to create a new password to allow the task to run?

  9. #9
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Automatically Send an Email with CDO at Specfic Date and Time

    Hello Orangeworker,

    To schedule a task you must be logged on as the administrator. The administrator account is generally password protected. If this is your own computer then logging on as the administrator should not be a problem. If you are trying to schedule a task on your company's network server then you will need to talk with your system administrator about scheduling a task. I doubt the system admin would tell you his/her password.

  10. #10
    Registered User
    Join Date
    03-04-2010
    Location
    South Florida
    MS-Off Ver
    Excel 2007
    Posts
    72

    Re: Automatically Send an Email with CDO at Specfic Date and Time

    Leith,

    I've got the "Scheduled Task" to work and it opens the file fine. I have authorized the file to open without having to manually confirm the macro as well. However, the macro is not running. At this point, I'm assuming that I am missing something from the code that I posted earlier that automatically starts the macro. Could you show me what I need to add?
    Thanks a lot for your help!

  11. #11
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Automatically Send an Email with CDO at Specfic Date and Time

    Hello Orangeworker;

    Here is how to setup your workbook to run the macro automatically.
    1. Copy the code below using Ctrl+C
    2. Open your workbook and press the Alt+F11 keys
    3. Click {b]ThisWorkbook[/b] in the Microsoft Excel Objects
    4. Press Ctrl+V
    5. Press Ctrl+S
    6. Close your workbook

    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    03-04-2010
    Location
    South Florida
    MS-Off Ver
    Excel 2007
    Posts
    72

    Re: Automatically Send an Email with CDO at Specfic Date and Time

    Leith,

    Thanks. I was messing around with this last night and got it to work by pasting the code right in "ThisWorkbook" (I altered it a little bit), then I just removed the module. This is the code that I used. Thanks for all your help.

    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    03-04-2010
    Location
    South Florida
    MS-Off Ver
    Excel 2007
    Posts
    72

    Re: Automatically Send an Email with CDO at Specfic Date and Time

    Leith,

    I'm having trouble marking the thread as "solved". I've got to leave my office right now, but I'll figure it out when I get back in!

  14. #14
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Automatically Send an Email with CDO at Specfic Date and Time

    Hello Orangeworker,

    Excellent work. Glad that is up and running. I will mark this post solved for you.


    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1