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

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))
                Else
                    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))
                Else
                    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?

Thanks,
      Jonathan
jdonagheAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
smitchamConnect With a Mentor Commented:
In the code you have posted you are casting the outlook object and not the message object.  Try

CType(v_Message,Outlook.MailItem).Send
0
 
William ElliottSr Tech GuruCommented:
i think you may just need to remove the  () from the send
0
 
jdonagheAuthor Commented:
You are partially right.  I made a mistake when I was coding.  I put Outlook.MailItem not Outlook_MailItem.

CType(v_Message,Outlook._MailItem).Send

Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.