Loading
Ozgrid Excel Help & Best Practices Forums

Excel Video Tutorials / Excel Dashboards Reports



Results 1 to 7 of 7

Thread: VBA for outlook to autosend email on login & logout from outlook

  1. #1
    Join Date
    1st February 2013
    Posts
    4

    VBA for outlook to autosend email on login & logout from outlook

    Hello All,

    I am a end user and as such do not hae much knowledge of VBA.
    What I am looking for is a code which can be use in outlook such that the moment a user login to outlook a mail is triggered out to a set recepient and set subject. Similarly when the user is closing outlook a mail again gets triggered.

    The objective here is capture the users outlook session time.

    I got most of the user on 2003 with a few exception on 2007.

    Kindly advice.

    Excel Video Tutorials / Excel Dashboards Reports


  2. #2
    Join Date
    1st September 2010
    Posts
    7,943

    Re: VBA for outlook to autosend email on login & logout from outlook

    Cross posted: http://www.pcreview.co.uk/forums/vba...-t4056033.html (and an older posting at http://www.vbforums.com/showthread.p...a-ID-of-choice)

    Please have another read of the rules you agreed to when you joined the forum. Rules #3...

    3. Do not cross-post without supplying a link to the duplicate question on the other forum.

    Cross posting without adding links to posts on other boards can waste time if similar solutions are provided on more than one board. Please update your post with links to any other threads you started and ensure that any future posts by you comply with the rules.

    Excel Video Tutorials / Excel Dashboards Reports


  3. #3
    Join Date
    21st November 2012
    Posts
    617

    Re: VBA for outlook to autosend email on login & logout from outlook

    Try something based on this:
    VB:
    Private Sub Application_MAPILogonComplete() 
        MsgBox "Logged on to Outlook" 
    End Sub 
     
    Private Sub Application_Quit() 
        MsgBox "Outlook exiting" 
    End Sub 
    
    
    Put the code in the ThisOutlookSession module.

    Please update your other threads with a link to this thread, so that people trying to help you on those other forums know that you've posted your question elsewhere and have a possible solution, otherwise they might be wasting their time.

    Excel Video Tutorials / Excel Dashboards Reports


  4. #4
    Join Date
    1st February 2013
    Posts
    4

    Re: VBA for outlook to autosend email on login & logout from outlook

    Thanks cytop for highlighting the miss.
    Yes I have uploaded the same query on the below links.
    http://www.pcreview.co.uk/forums/vba...-t4056033.html
    http://www.vbforums.com/showthread.p...a-ID-of-choice

    However Ozgrid is the only one where I have recived a reply.
    Thanks indeed.

    Excel Video Tutorials / Excel Dashboards Reports


  5. #5
    Join Date
    1st February 2013
    Posts
    4

    Re: VBA for outlook to autosend email on login & logout from outlook

    Thanks john for the code, however I was looking for a code which triggered a mail automatically post login and just after log off.
    I have managed to create the below code, the issue I am facing is that, I am succesfully able to send the mail on login, but everytime i close outlook, i get an error on the second part of the code where it should send a logout mail before exiting.

    Can you help me fix it.
    _______________________________________________________________________________
    Private Sub Application_MAPILogonComplete()
    Dim OutApp As Object
    Dim OutMail As Object
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)
    On Error Resume Next
    With OutMail
    .To = "abc@xyz.com"
    .CC = ""
    .BCC = ""
    .Subject = "Login for the day"
    .Body = ""
    .Attachments
    .Display
    End With
    On Error GoTo 0
    Set OutMail = Nothing
    Set OutApp = Nothing
    End Sub
    _____________________________________________________________________________
    Private Sub Application_Quit()
    Dim OutApp As Object
    Dim OutMail As Object
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)
    With OutMail
    .To = abc@xyz.com
    .CC = ""
    .BCC = ""
    .Subject = "Logout for the day"
    .Body = ""
    .Attachments
    .Display
    End With
    Set OutMail = Nothing
    Set OutApp = Nothing
    End Sub
    ________________________________________________________________________

    Excel Video Tutorials / Excel Dashboards Reports


  6. #6
    Join Date
    1st February 2013
    Posts
    4

    Re: VBA for outlook to autosend email on login & logout from outlook

    Thanks everyone, I figured it out, the code works fine now.
    Got some help from the below link.
    http://www.vbaexpress.com/forum/showthread.php?t=36205


    ______
    Private Sub Application_MAPILogonComplete()
    Dim OutApp As Object
    Dim OutMail As Object
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)
    On Error Resume Next
    With OutMail
    .To = "Amin, Shashikant [ICG-CTS NE]"
    .CC = ""
    .BCC = ""
    .Subject = "Login for the day"
    .Body = ""
    .Attachments
    .Send
    End With
    On Error GoTo 0
    Set OutMail = Nothing
    Set OutApp = Nothing
    End Sub
    Private Sub Application_Quit()
    Dim OutApp As Object
    Dim OutMail As Object
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)
    With OutMail
    .To = "Amin, Shashikant [ICG-CTS NE]"
    .CC = ""
    .BCC = ""
    .Subject = "Logout for the day"
    .Body = ""
    .Attachments
    .Send
    End With
    Set OutMail = Nothing
    Set OutApp = Nothing
    End Sub

    Excel Video Tutorials / Excel Dashboards Reports


  7. #7
    Join Date
    21st November 2012
    Posts
    617

    Re: VBA for outlook to autosend email on login & logout from outlook

    Glad you got it working. My code was just a template showing the relevant Outlook event handlers to focus your searches for a solution.

    Excel Video Tutorials / Excel Dashboards Reports


Thread Information

Users Browsing this Thread

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

Possible Answers

  1. autosend outlook
    By christian09 in forum Excel and/or Email Help
    Replies: 1
    Last Post: September 20th, 2012, 19:17
  2. Tracking total time of employee login/logout times
    By imcutthroat in forum EXCEL HELP
    Replies: 1
    Last Post: December 22nd, 2010, 05:58
  3. Excel 2007 - LogIn Logout
    By elergems in forum EXCEL HELP
    Replies: 2
    Last Post: November 9th, 2010, 11:06
  4. Replies: 8
    Last Post: August 23rd, 2008, 14:42
  5. Replies: 3
    Last Post: April 12th, 2004, 13:31

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
  •  
porno