I'm trying to learn how to open a new email message from excel. I am recieveing a run time error when I try to set the recipients. Can anyone see what I am doing wrong?
[!]Run-time error '13'
Type mismatch[/!]
[!]Run-time error '13'
Type mismatch[/!]
Code:
[COLOR=darkblue]Private Sub[/color] cmdMail_Click()
[COLOR=darkblue]Dim[/color] olApp [COLOR=darkblue]As[/color] Outlook.Application
[COLOR=darkblue]Dim[/color] olMail [COLOR=darkblue]As[/color] MailItem, olSendTo [COLOR=darkblue]As[/color] Recipients
[COLOR=green]'open Outlook[/color]
[COLOR=darkblue]Set[/color] olApp = CreateObject("Outlook.Application")
[COLOR=green]'Create mail message[/color]
[COLOR=darkblue]Set[/color] olMail = olApp.CreateItem(olMailItem)
[COLOR=darkblue]With[/color] olMail
[highlight]Set olSendTo = .Recipients.Add("test@sbcglobal.net")[/highlight] [!]<-- error[/!]
olSendTo.Type = olTo
.Subject = "Test Test Test"
.body = "message text"
[COLOR=darkblue]End With[/color]
olMail.Display