Sending Emails through outlook RRS feed

  • Question

  • Hi,

          I used the following code to send emails through outlook using vb.net. I installed windows xp professioanal,ms visual studio 2005, ms outlook 2002. But i am getting the following error. Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT))".

    ' Create an Outlook application.
            Dim oApp As Object
            oApp = New Outlook.Application()
            'Dim oApp As Outlook._Application
            'oApp = New Outlook.Application()

            ' Create a new MailItem.
            Dim oMsg As Outlook._MailItem
            oMsg = oApp.CreateItem(Outlook.OlItemType.olMailItem)
            oMsg.Subject = "Test-1"
            oMsg.Body = "Test-1" & vbCr & vbCr

            ' TODO: Replace with a valid e-mail address.
            oMsg.To = "abc@gmail.com"

            ' Add an attachment
            ' TODO: Replace with a valid attachment path.
            Dim sSource As String = "C:\Hello.txt"
            ' TODO: Replace with attachment name
            Dim sDisplayName As String = "Hello.txt"

            Dim sBodyLen As String = oMsg.Body.Length
            Dim oAttachs As Outlook.Attachments = oMsg.Attachments
            Dim oAttach As Outlook.Attachment
            'oAttach = oAttachs.Add(sSource, , sBodyLen + 1, sDisplayName)

            ' Send

            ' Clean up
            oApp = Nothing
            oMsg = Nothing
            oAttach = Nothing
            oAttachs = Nothing

    how to solve this error. Pls give ur suggesstions. Its very urgent. Thanks in advance.

    • Moved by nobugz Thursday, July 16, 2009 12:22 PM not a bcl q (From:.NET Base Class Library)
    Thursday, July 16, 2009 5:21 AM


All replies