Send Each Row Every Day On A Specified Time

  • HI Experts,


    I have a small requirement.


    I want send the each row every day on a specified time. For instance, I will send row1, today at 2.00 AM and row2 tomorrow at 2.00 AM and row the subsequent day day at 2.00 AM etc.,



    When I tried this code, it is giving Run time error message "Outlook does not recognize one or more names". I am not sure what am I missing here. Instead, if I use .Display in place of .Send it is composing the mail with correct values (including the delivery time).



    Also is it possible that, every day mail is sent automatically, instead of I running the Vb code manually...?!


    Thanks in advance.

  • Re: Send Each Row Every Day On A Specified Time


    Thanks for your reply Dave.



    Code
    Application.OnTime
      TimeValue ("02:00:00"), "My Macro"


    I have added the above lines of code in my macro and the Compiler error shows 'Argument not optional'.


    Below line of code in the Workbook open event


    Code
    Application.OnTime TimeValue("02:00:00"), "My Macro"


    Kindly suggest where I am going wrong.


    Thanks in advance.

  • Re: Send Each Row Every Day On A Specified Time


    Quote

    I have added the above lines of code in my macro and the Compiler error shows 'Argument not optional'.

    It MUST be on one line, or like;

    Code
    Application .OnTime _ 
    TimeValue ("02:00:00"), "My Macro"
  • Re: Send Each Row Every Day On A Specified Time


    Hi Dave,


    You got it right.!
    I just copied those lines of code from the link which you have mentioned and it's been some couple of years since I have looked at some vb code.


    But, still the old problem remains, where if I replace 'Display' with 'Send', run time error is shown up.


    Thanks for your time.


    HI VBA Noob,
    Thanks for your reply. I have used the correct macro name.

  • Re: Send Each Row Every Day On A Specified Time


    I tested your code with Outlook 2007 and it worked normally. Did you try to execute the code line by line, and which line gets the error ?
    Try the following :
    in the VBE window, click on "tools", "references" and select "MS Outlook xx Object Library". Then, change for :

    Code
    Dim OutApp As Outlook.Application
        Dim OutMail As MailItem


    HTH
    Daniel

  • Re: Send Each Row Every Day On A Specified Time


    Hi Daniel,


    Sorry for the delayed reply.


    Thanks for taking time to reply to my post.


    I am using Microsoft Excel 2003. The option is already checked and when I have added the lines of code you mentioned it gave the compile error: "User-defined type not defined".


    Am I missing anything else..?

  • Re: Send Each Row Every Day On A Specified Time


    I tested your code with Office 2003 with no error. Can you copy your data and macros in a new workbook and check if you get the same error ? If so, can you post here a sample file ?
    Daniel

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!