Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving attachments from an Exchange Public Folder

Status
Not open for further replies.

bxgti4x4

Technical User
Feb 22, 2002
167
GB
We have recently upgraded from Mailgate to Microsoft Exchange. In Outlook on my PC I had the following code to saved a particular attachment to a specified folder:

Code:
Dim myOlApp As Outlook.Application
    Dim myInspector As Outlook.Inspector
    Dim myItem As Outlook.MailItem
    Dim myAttachments As Outlook.Attachments
    Set myOlApp = CreateObject("Outlook.Application")
    Set myInspector = myOlApp.ActiveInspector
    If Not TypeName(myInspector) = "Nothing" Then
        If TypeName(myInspector.CurrentItem) = "MailItem" Then
            Set myItem = myInspector.CurrentItem
            Set myAttachments = myItem.Attachments
            'Prompt the user for confirmation
            Rem Dim strPrompt As String
            Rem strPrompt = "Are you sure you want to save the first attachment in the current item to the C:\ folder? If a file with the same name already exists in the destination folder, it will be overwritten with this copy of the file."
            Rem If MsgBox(strPrompt, vbYesNo + vbQuestion) = vbYes Then
                myAttachments.Item(1).SaveAsFile "N:\DOCS2\Positions\" & _
                myAttachments.Item(1).DisplayName
            Rem End If
        Else
            MsgBox "The item is of the wrong type."
        End If
The message which contains the attachment I wish to save now appears in an Exchange Public Folder and, when I run the code, the message box appears telling me that the item is of the wrong type.

I think the problem lies in the phrase "Dim myItem As Outlook.MailItem" but I cannot find any information which refers to Exchange. I would be grateful if someone could set me right.

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top