Results 1 to 19 of 19

receive email automatically when excel file is updated

Threaded View

  1. #9
    Registered User
    Join Date
    08-21-2008
    Location
    USA
    Posts
    27
    I created a sample work book named sample08.xls
    I have created two rows and saved it. Then i created the macro as you said.
    Then i tried to add another row into the sheet and saved it.
    Then i checked my email, but no emails.
    yes, i checked my out look email(my work email is already configured to outlook and i gave my work email in the code below).

    Do you mind checking if the code actually is working?
    Option Explicit
    
    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
        Dim OutApp As Object
        Dim OutMail As Object
        Const SendTo As String = "myname@company.com"
    
        Set OutApp = CreateObject("Outlook.Application")
    
        OutApp.Session.Logon
        Set OutMail = OutApp.CreateItem(0)
    
        With OutMail
            .To = SendTo
            .Subject = ThisWorkbook.sample08 " has been amended"
            .Body = " add a message here"
            .Send
        End With
    
        Set OutMail = Nothing
        Set OutApp = Nothing
    End Sub
    Last edited by royUK; 08-23-2008 at 01:59 PM. Reason: add code tags

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. An Excel file is missing
    By nicknil in forum Excel General
    Replies: 2
    Last Post: 04-04-2008, 02:14 AM
  2. determining the Directory of an Excel file
    By Ingenieros_en_a in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-28-2007, 05:59 AM
  3. Automatically Save an excel file at a certain time
    By RobbieBobbie23 in forum Excel General
    Replies: 2
    Last Post: 06-26-2007, 02:16 PM
  4. Replies: 0
    Last Post: 06-25-2007, 11:56 AM
  5. Importing data from another excel file automatically
    By rondarat in forum Excel General
    Replies: 10
    Last Post: 03-08-2007, 12:11 AM

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