Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27514

Try and Catch with outlook

$
0
0
With this code i send a email with outlook.


Code:


 Dim application = New Microsoft.Office.Interop.Outlook.Application
        Dim outlookEmail = CType(application.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem), MailItem)

        outlookEmail.To = "*********@gmail.com"

        outlookEmail.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatPlain

        outlookEmail.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceNormal

        outlookEmail.Body = ("Test")
        outlookEmail.Subject = ("Ok")

        outlookEmail.Display(False)
        outlookEmail.Send()

it works great , but when there is no outlook on the pc installed the programma crash.

Try and catch is not working ?

The error is

Code:

'Catch' cannot catch type 'Microsoft.Office.Interop.Outlook.Exception' because it is not 'System.Exception' or a class that inherits from 'System.Exception'.
Who can help me ?

Viewing all articles
Browse latest Browse all 27514

Trending Articles