+ Reply to Thread
Results 1 to 6 of 6

VBA to Select 2nd Outlook Account and Download attachments

  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.

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

    Re: VBA to Select 2nd Outlook Account and Download attachments

    Can anyone help me please?

  3. #3
    Registered User
    Join Date
    06-13-2015
    Location
    Amsterdam
    MS-Off Ver
    windows 7
    Posts
    2

    Re: VBA to Select 2nd Outlook Account and Download attachments

    Why not forward the e-mail from the second to the first e-mail account?
    Last edited by Brasilva; 08-25-2015 at 07:34 AM.

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

    Re: VBA to Select 2nd Outlook Account and Download attachments

    Hi Brasilva,

    Thank you for your reply.

    Well i want to save some space in my primary mailbox.

    Basically i would want to use the default account for normal purposes, but for reporting i want to use the second account.

    At your disposal.

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

    Re: VBA to Select 2nd Outlook Account and Download attachments

    Update -

    Please see also the cross post on another website: http://www.vbaexpress.com/forum/show...ad-attachments

    My apologies i havent read carefully rule 8.

  6. #6
    Registered User
    Join Date
    06-13-2015
    Location
    Amsterdam
    MS-Off Ver
    windows 7
    Posts
    2

    Re: VBA to Select 2nd Outlook Account and Download attachments

    Hello,

    Fair enough, I wish I could offer you a solution but I don't have one.
    Really sorry.

    I hope someone will give you the solution.

+ 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] 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. [SOLVED] 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. 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. [SOLVED] 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