Results 1 to 1 of 1

Thread: Outlook Attachments

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2010
    Posts
    19

    Outlook Attachments

    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 (outlook attachment) is dropped onto the main form it saves that file to a specific directory. I have the following code which seems to work for any file other than outlook attachments (possibly because outlook's drag and drop feature is defined differently?). Does anyone know why it does not work for outlook (2003 to be exact)?

    Code:
    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
    Last edited by error1f1f; Mar 1st, 2010 at 07:12 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width