Mail löschen

  • VB.NET

Es gibt 2 Antworten in diesem Thema. Der letzte Beitrag () ist von lris08.

    Hallo,

    versuche über kleinen Code erst eine Mail speichern zu lassen (funktioniert super) und anschließend soll diese MAil gelöscht werden.

    VB.NET-Quellcode

    1. Dim objOutlook As Microsoft.Office.Interop.Outlook._Application
    2. objOutlook = New Microsoft.Office.Interop.Outlook.Application
    3. Dim mail As Microsoft.Office.Interop.Outlook.MailItem
    4. mail = objOutlook.ActiveExplorer.Selection.Item(1)
    5. Dim MailAbsAdd As String = mail.SenderName
    6. Dim MailEmpAdd As String = mail.To
    7. Dim MailDatum As String = mail.ReceivedTime
    8. MailDatum = MailDatum.Substring(0, 10)
    9. Dim MailBetref As String = mail.Subject
    10. If CountChar(MailEmpAdd, ";") > 1 Then
    11. MailEmpAdd = "mehrere Empfänger"
    12. End If
    13. Try
    14. mail.SaveAs(Datei)
    15. mail.Delete()
    16. Catch ex As Exception
    17. MsgBox(ex.Message)
    18. Exit Sub
    19. End Try


    Gibt aber ne Fehlermeldung aus, dass:

    Outlook kann dieses Element nicht löschen


    Woran liegt das problem ? Verstehs nicht...

    Gruß
    lris
    so gehts:

    VB.NET-Quellcode

    1. Private Sub Mail_Verschieben()
    2. Dim App As Microsoft.Office.Interop.Outlook.Application
    3. App = New Microsoft.Office.Interop.Outlook.Application
    4. Dim Folder As Microsoft.Office.Interop.Outlook.MAPIFolder
    5. Dim Items As Microsoft.Office.Interop.Outlook.MailItem
    6. Items = App.ActiveExplorer.Selection.Item(1)
    7. Folder = App.GetNamespace("Mapi").GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderDeletedItems)
    8. Items.Move(Folder)
    9. Items = Nothing
    10. End Sub