Results 1 to 6 of 6

VBA to Select 2nd Outlook Account and Download attachments

Threaded View

  1. #1
    Registered User
    Join Date
    10-21-2014
    Location
    Iasi
    MS-Off Ver
    2010
    Posts
    6

    VBA to Select 2nd Outlook Account and Download attachments

    Hello,

    I have the code below:

    Const olFolderInbox As Integer = 6

    Const AttachmentPath As String = "C:\Temp\"

    Sub DownloadAttachmentFirstUnreadEmail()
    Dim oOlAp As Object, oOlns As Object, oOlInb As Object
    Dim oOlItm As Object, oOlAtch As Object


    Dim NewFileName As String
    NewFileName = AttachmentPath & Format(Date, "DD-MM-YYYY") & "-"


    Set oOlAp = GetObject(, "Outlook.application")
    Set oOlns = oOlAp.GetNamespace("MAPI")
    Set oOlInb = oOlns.GetDefaultFolder(olFolderInbox)


    If oOlInb.Items.Restrict("[UnRead] = True").Count = 0 Then
    MsgBox "NO Unread Email In Inbox"
    Exit Sub
    End If


    For Each oOlItm In oOlInb.Items.Restrict("[UnRead] = True")

    If oOlItm.Attachments.Count <> 0 Then
    For Each oOlAtch In oOlItm.Attachments

    oOlAtch.SaveAsFile NewFileName & oOlAtch.Filename
    Exit For
    Next
    Else
    MsgBox "The First item doesn't have an attachment"
    End If
    Exit For
    Next
    End Sub

    This code works perfectly and downloads the latest unread email, from my default Outlook account.
    However i want to use the second Outlook account.

    Can you please help me?

    Thank you.
    Last edited by Bogdan Scorpion; 08-25-2015 at 02:26 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Create E-mails in a G-Mail account with attachments using VBA
    By spiwere in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 05-26-2017, 02:54 PM
  2. Help On My Outlook Attachments
    By Don Adeks in forum Outlook Formatting & Functions
    Replies: 3
    Last Post: 06-09-2015, 04:14 AM
  3. User form to add attachments and send the form and attachments via outlook
    By scorchio83 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-21-2013, 03:46 AM
  4. Excel Macro to download email attachments from MS Outlook.
    By abhay_547 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-06-2010, 02:10 PM
  5. [SOLVED] Excel Macro to download attachments from multiple sub folders of outlook
    By abhay_547 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-31-2010, 09:32 AM
  6. Customizing Outlook with attachments!
    By nandhamnk in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-01-2008, 04:48 AM
  7. opening zip outlook attachments
    By Rich in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-03-2006, 05:20 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