troubleshooting Question

Error Using Outlook in VB.Net

Avatar of Chuck Wood
Chuck WoodFlag for United States of America asked on
Visual Basic.NET
5 Comments1 Solution356 ViewsLast Modified:
I have code that was working until about three days ago.
    Public Function Email(ByVal strTo As String, ByVal strSubject As String, _
      ByVal strBody As String, Optional ByVal strCC As String = "", Optional ByVal strAttachment As String = "", _
      Optional ByVal fDeliveryReq As Boolean = False, Optional ByVal fReadRecpt As Boolean = False) As Boolean
        Email = False
        Dim olMailItem As Int16, olImportanceHigh As Int16
        olMailItem = 0
        olImportanceHigh = 2
        ' set the initial state of the function
        Email = False
        Dim outl As New Outlook.Application, intI As Integer
        ' create an email item
        Dim outMsg As Outlook.MailItem
        outMsg = outl.CreateItem(olMailItem)
        With outMsg
            ' set the message parts
            .To = strTo
            .Subject = strSubject
            .Body = strBody
            .CC = strCC
            .Importance = olImportanceHigh
            .OriginatorDeliveryReportRequested = fDeliveryReq
            .ReadReceiptRequested = fReadRecpt
            ' send the message
            ' set the final state of the function
            Email = True
        End With
    End Function
End Module

When this code is run, it errors at "Dim outl As New Outlook.Application" with this error:

An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in CSIDTest.exe
Additional information: The RPC server is unavailable.

I am using VB.Net in Visual Stuio 2003. I have a reference to the Microsoft Outlook 9.0 Object Library.
Again, this code worked perfectly until recently.

What is causing this error?
Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 1 Answer and 5 Comments.
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>


Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 1 Answer and 5 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004