Results 1 to 3 of 3

Thread: [RESOLVED] Email backup automatically

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2008
    Posts
    790

    Resolved [RESOLVED] Email backup automatically

    I have a VB6 application that stores data in an excel spreadsheet first and then into a remote mySQL database.

    I save to Excel because of its graphs capabilities (I have my application print an excel spreadsheet once the data is entered into it), and because I think it would be a nice backup file for my application (in case the server is down or the internet connection is dropped temporarily). All data entries are saved on a separate spreadsheet within my workbook.

    The program is on a computer that I do not have access to all the time, so I would like the excel workbook to be emailed to me when I want it.

    It would be nice to have it automatically email me once a week (I assume this is the most efficient way of doing this).

    I can email using CDO without any problems, but I don't know how to set this up to email every 7 days, for instance. I do have a timer on my main form that will update two labels with the current date and time. The timer's interval is set to 1.

    Any tips or advice?

    Maybe there is an easier way of doing this also, that I am not aware of, to get access to my excel file whenever I want it.

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2008
    Posts
    790

    Re: Email backup automatically

    Here is what I have just done:

    I have the date and time shown in labels on my main form, as explained.

    If the label time reaches a certain time (I will have it set for like 4:00:00 AM) then my application will connect remotely into mySql database.

    I made a table called sendbackup with three fields (ID, date_sent, days_next).

    The table is queried and the records are sorted by date_sent descending order.

    I used the DateDiff () function to count how many days there are between NOW and the date_sent date. If the number of days is >= the value in days_next then the email is sent.

    After the email is sent to me with the file, a record is inserted into the sendbackup table where today's date is 'date_sent' and 'days_next' is 7 (one week, by default).

    This way I can always change how often I want the backup file emailed to me by accessing the database... if I find the most recent date_sent record and change the days_next field to any number of days for my next email.

    I use > or EQUAL TO in my query just in case the internet connection was down when it tried to send the backup file. I would then get the backup a day later, assuming my connection is made.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2008
    Posts
    790

    Re: Email backup automatically

    I also made a field called activated where 0 = not activated and 1 = activated.

    During my query, the activated must also equal "1" else, it won't send.

    This way, if I don't want the emails any longer, I can set the last "date_sent" record to 0 in its activated field.

Posting Permissions

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



Click Here to Expand Forum to Full Width