I have a built-in folder in my Outlook called "Reports". Each email in this folder has an email with an attachment. I want to use ACCESS VBA to save the attachment to the local drive from the "Reports" folder in Outlook on my computer. Here's the code that I've done so far, but gives me errors Please help:
name as the name of the name of the space dim inbox as the default name of the Outlook.MAPIFolder dim folder As the Outlook.MAPIFolder dim item, the object dim asmt attachment set the integer string as string filename in the form of filename Ns = GetNamespace ("MAPI") set Inbox = ns.Folders.Item ("Report") // I get an error in this line, an object can not get I = 0 If there is no I = 0 inbox.Items.Count = 0 then there is no message in the "Inbox." MsgBox, VbInformation, _ "nothing found" for each item in the Inbox in the sub-inbox. Item for each item in the item. Attachments FileName = "C: \ Automation \" & amp; ATMt.FileName ATMt.SaveAsFileFileName // Here is another error, the method says I = I + 1 next Atmt next item
Is your report folder in your Inbox folder? You might need to do something like this:
Set NS = GnomePass ("MAPI") set Inbox = N. Set the gate default folder (olFolderInbox) RptFolder = Inbox.Folders ("Report") Your syntax looks correct to save the attachment (not right for VBA in addition to your comments). You can print the file name that you want to see if it is a valid name or not. And I believe that you have mentioned the automation folders that you have mentioned.
Update: Try to declare your ATMT as Outlook. Attachments. There is such a thing as access. Attachment in which there is no saving ffile method, and it is probably the first one to choose. If you include the name of the library, then you need it you need it. Update 2: To access your Report folder, the only way you want to get the Inbox folder are currently, then get its parent , Then get the report folder. Set ns = GetNamespace ("MAPI") Set Inbox = ns.GetDefaultFolder (olFolderInbox) Mailbox = Inbox. Set parent to RptFolder = Mailbox.Folders ("Report") Another way to scan an item under "NS" to find one that starts with "Mailbox" Then get the report folder, it is a bit more cumbersome than receiving the inbox parents, it seems too cumbersome, but I could not find any way to get directly into the mailbox folder.
Comments
Post a Comment