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


Reply With Quote
