locked
Extract Outlook Attachments RRS feed

  • Question

  • I am not quite sure where to ask this but I was wondering if anyone knew a way to have vb extract an attachment from an outlook email and save it to a specified directory. What I have is a program that when a file is dropped onto the main form it saves that file to a specific directory. I have the following code which seems to work for anything other than Outlook (possibly because outlook's drag and drop feature is defined differently?):

    Private Sub Form1_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles MyBase.DragDrop
            Try
                If (e.Data.GetDataPresent(DataFormats.FileDrop)) Then
                    e.Effect = DragDropEffects.Move
                    Dim file As String = CType(e.Data.GetData(DataFormats.FileDrop), Array).GetValue(0).ToString()
                    MsgBox(file)
                    System.IO.File.Copy(file, "C:\Outlook\files\")
                End If
            Catch ex As Exception
                MessageBox.Show("Invalid File!", "Error")
            End Try
    End Sub
    
    Private Sub Form1_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles MyBase.DragEnter
            If (e.Data.GetDataPresent(DataFormats.FileDrop)) Then
                e.Effect = DragDropEffects.Copy
            End If
    End Sub

    Monday, March 1, 2010 6:51 PM

Answers

All replies