Go Premium for a chance to win a PS4. Enter to Win


'Send' is ambiguous across the inherited interfaces 'Outlook._MailItem' and 'Outlook.ItemEvents_10_Event'.

Posted on 2007-09-10
Medium Priority
Last Modified: 2012-06-21
I am trying to send a message through Outlook 2003 using vb.net 2002.  But I get this error message:
'Send' is ambiguous across the inherited interfaces 'Outlook._MailItem' and 'Outlook.ItemEvents_10_Event'.

I checked this link: http://support.microsoft.com/?kbid=315981

I tried applying both solutions, but could not get either to work.  Here is my code:

Sub SendMessage(ByVal s_AttachmentPath As String, ByVal S_Address As String, ByVal S_Body As String, ByVal S_Subject As String)
        'The purpose of this function is to send an attachment e-mail

        'Declare the outlook variables
        Dim v_Outlook As New Outlook.ApplicationClass()
        Dim v_Message As Outlook.MailItem
        Dim v_Recipient As Outlook.Recipient
        Dim v_Attachment As Outlook.Attachment

        Dim strTempAddress As String    'temporary storage for e-mail address
        Dim strAddress As String        'storage for single e-mail addresses
        Dim intPosition As String       'stores the position of the ; to split e-mail addresses

        Dim strTempAttach As String    'temporary storage for attachment paths
        Dim strAttachment As String    'storage for single attachment path

        'Start the outlook session
        v_Outlook = New Outlook.ApplicationClass()

        'Create the Message
        v_Message = v_Outlook.CreateItem(Outlook.OlItemType.olMailItem)

        With v_Message

            'Stores all of the attachment paths that was passed in
            strTempAttach = s_AttachmentPath

            intPosition = 1

            'While loop to go through the e-mail address to determine if there are multiple addresses
            While intPosition <> 0
                intPosition = InStr(intPosition + 1, strTempAttach, ";", vbBinaryCompare)
                If intPosition <> 0 Then
                    strAttachment = Left(strTempAttach, intPosition - 1)
                    strTempAttach = Right(strTempAttach, Len(strTempAttach) - (intPosition + 1))
                    strAttachment = strTempAttach
                End If

                'Add attachment
                If Not IsNothing(strAddress) Then
                    v_Attachment = .Attachments.Add(strAttachment)
                End If
            End While

            'Stores all of the e-mail addresses that was passed in
            strTempAddress = S_Address

            intPosition = 1

            'While loop to go through the e-mail address to determine if there are multiple addresses
            While intPosition <> 0
                intPosition = InStr(intPosition + 1, strTempAddress, ";", vbBinaryCompare)
                If intPosition <> 0 Then
                    strAddress = Left(strTempAddress, intPosition - 1)
                    strTempAddress = Right(strTempAddress, Len(strTempAddress) - (intPosition + 1))
                    strAddress = strTempAddress
                End If
                'Adds each recipient
                v_Recipient = .Recipients.Add(strAddress)
            End While

            v_Recipient.Type = Outlook.OlMailRecipientType.olTo

            'Set the subject line
            .Subject = S_Subject

            'Set the body text
            .Body = S_Body

        End With

        'Send the message
        CType(v_Outlook, Outlook.MailItem).Send()

        'clear the variables
        v_Outlook = Nothing
        v_Message = Nothing
        v_Recipient = Nothing

    End Sub

Can someone tell me what I am doing wrong?

Question by:jdonaghe
LVL 19

Expert Comment

ID: 19865263
i think you may just need to remove the  () from the send

Accepted Solution

smitcham earned 1500 total points
ID: 19865517
In the code you have posted you are casting the outlook object and not the message object.  Try


Author Comment

ID: 19866416
You are partially right.  I made a mistake when I was coding.  I put Outlook.MailItem not Outlook_MailItem.



Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question