+ Reply to Thread
Results 1 to 8 of 8

outlook automation

Hybrid View

  1. #1
    Registered User
    Join Date
    01-08-2014
    Location
    india
    MS-Off Ver
    Excel 2010
    Posts
    23

    outlook automation

    Good day experts. Please help me in solving this issue.

    I have a macro that will extract the subject and received date and EntryID from the mails to excel, but my requirement was,

    (It should extract the subject and received date and time, content of the mail.) if subject and received date and time, content of the mail are same.. it should not be extracted to excel.. iam telling this condition to stop duplication of mail..


    Please help me in doing this..
    Sub ReadEmails()
    
            'Stop Screen Updates
            Application.ScreenUpdating = False
            ' Then remember to run automatic calculations back on
            Application.Calculation = xlCalculationManual
            Application.EnableEvents = False
    
    'set this to the folder
    Set Olf = CreateObject("Outlook.Application").GetNamespace("MAPI").Folders(1).Folders("inbox")
    
           
    i = Olf.Items.Count + 1
    LR = Range("A65536").End(xlUp).Row
    r = 1
    
    Do Until r = i
    
    subs = Olf.Items(r).Subject
    daterec = Olf.Items(r).ReceivedTime
    strID = Olf.Items(r).EntryID
    
    
    
    Worksheets("Sheet1").Cells(LR, 1).Value = subs
    Worksheets("Sheet1").Cells(LR, 2).Value = daterec
    Worksheets("Sheet1").Cells(LR, 3).Value = strID
    
    r = r + 1
    LR = LR + 1
    
    Loop
    
            'Stop Screen Updates
            Application.ScreenUpdating = True
            ' Then remember to run automatic calculations back on
            Application.Calculation = xlCalculationAutomatic
            Application.EnableEvents = True
    End Sub

  2. #2
    Registered User
    Join Date
    01-08-2014
    Location
    india
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: outlook automation

    Good day.. Experts.. please help me in doing this, waiting for reply

  3. #3
    Registered User
    Join Date
    01-08-2014
    Location
    india
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: outlook automation

    Good day experts,, Please help me in doing this.

    Mails subject and received date will be extracted to the excel from (row 1), but i have titles in the (row 1. So edit this macro to copy from
    (row 2),, Please help me


    Sub ReadEmails()
    
            'Stop Screen Updates
            Application.ScreenUpdating = False
            ' Then remember to run automatic calculations back on
            Application.Calculation = xlCalculationManual
            Application.EnableEvents = False
    
    'set this to the folder
    Set Olf = CreateObject("Outlook.Application").GetNamespace("MAPI").Folders
    
    (1).Folders("inbox")
    
           
    i = Olf.Items.Count + 1
    LR = Range("A65536").End(xlUp).Row
    r = 1
    
    Do Until r = i
    
    subs = Olf.Items(r).Subject
    daterec = Olf.Items(r).ReceivedTime
    
    
    
    
    Worksheets("Sheet1").Cells(LR, 4).Value = subs
    Worksheets("Sheet1").Cells(LR, 3).Value = daterec
    
    
    
    r = r + 1
    LR = LR + 1
    
    Loop
    
            'Stop Screen Updates
            Application.ScreenUpdating = True
            ' Then remember to run automatic calculations back on
            Application.Calculation = xlCalculationAutomatic
            Application.EnableEvents = True
    End Sub

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: outlook automation

    Hi, Superking,

    you should take your time and have a read through the forum rules and donīt panic and push your thread unless you have new information (your second code shows an error when copying it as the line continuation is broken).

    Maybe like this:
    Sub ReadEmails()
    Dim OlF As Object
    Dim i As Integer
    Dim r  As Long
    
    With Application
      'Stop Screen Updates
      .ScreenUpdating = False
      ' Then remember to run automatic calculations back on
      .Calculation = xlCalculationManual
      .EnableEvents = False
    End With
    
    'set this to the folder
    On Error Resume Next
    Set OlF = CreateObject("Outlook.Application").GetNamespace("MAPI").Folders(1).Folders("inbox")
    On Error GoTo 0
    If Not OlF Is Nothing Then
      i = OlF.Items.Count + 1
      r = 1
      
      Do Until r = i
        With Worksheets("Sheet1")
          .Cells(r + 1, 4).Value = OlF.Items(r).Subject
          .Cells(r + 1, 3).Value = OlF.Items(r).ReceivedTime
          r = r + 1
        End With
      Loop
    End If
    
    With Application
      'Stop Screen Updates
      .ScreenUpdating = True
      ' Then remember to run automatic calculations back on
      .Calculation = xlCalculationAutomatic
      .EnableEvents = True
    End With
    End Sub
    You should take care to clear contents from the sheet prior to writing to it.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  5. #5
    Registered User
    Join Date
    01-08-2014
    Location
    india
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: outlook automation

    Good day

    @ HaHoBe

    Really thanks for your help, it works well..

    How can i get the follow up column,size, attachment,etc., iam asking this for my knowledge..

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: outlook automation

    Hi, superking,

    as I donīt know what you would like to see where maybe this sniplet may give you a hint:
            With OLF.Items(i)
                EmailCount = EmailCount + 1
                Cells(EmailCount + 1, 1).Formula = .subject
                Cells(EmailCount + 1, 2).Formula = Format(.ReceivedTime, "dd.mm.yyyy hh:mm")
                Cells(EmailCount + 1, 3).Formula = .Attachments.Count
                Cells(EmailCount + 1, 4).Formula = Not .UnRead
                Cells(EmailCount + 1, 4).Formula = .Recipients.Count
                Cells(EmailCount + 1, 5).Formula = .SenderName
            End With
    Ciao,
    Holger

  7. #7
    Registered User
    Join Date
    01-08-2014
    Location
    india
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: outlook automation

    Good day,

    @ HaHoBe, Thanks for your help.

    As per your previous post we use the below code for extracting the subject and receivedtime...

    But for my knowledge iam asking, how can we extract other columns like this, Example (followup, size, attachment, Category,From, TO, CC, BCC,
    other columns in view tab in outlook.


     With Worksheets("Sheet1")
          .Cells(r + 1, 4).Value = OlF.Items(r).Subject
          .Cells(r + 1, 3).Value = OlF.Items(r).ReceivedTime

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] VBA Macro to print to Pdf format and place as attachment in Outlook (Excel & Outlook 2007)
    By Webman1012 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-29-2013, 01:25 PM
  2. excel, outlook, automation
    By npgandlove in forum Excel General
    Replies: 1
    Last Post: 03-07-2011, 05:07 PM
  3. outlook 2007 automation
    By nuttycongo123 in forum Outlook Programming / VBA / Macros
    Replies: 81
    Last Post: 02-16-2011, 05:58 PM
  4. Outlook Automation of Excel Input
    By ShannonLarson in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-21-2007, 07:56 AM
  5. [SOLVED] Outlook Automation Error Problem - Can't locate Outlook Module
    By Allan P. London in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-14-2005, 06:05 PM

Tags for this Thread

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