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_Eve
nt'.
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(Outlo
ok.OlItemT
ype.olMail
Item)
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(strAttach
ment)
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.OlMailRecipientTyp
e.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
CType(v_Message,Outlook.Ma