Reputation: 1
On the line "EmailItem.To = Str(Sheet4.Cells(1, 2))" when i try to run it it comes up as a mismatch error how would i fix this?
Here is the code
Sub SendEmail_Example1()
Dim EmailApp As Outlook.Application
Dim Source As String
Set EmailApp = New Outlook.Application
Dim EmailItem As Outlook.MailItem
Set EmailItem = EmailApp.CreateItem(olMailItem)
EmailItem.To = Str(Sheet4.Cells(1, 2))
EmailItem.CC = "[email protected]"
EmailItem.Subject = "Test Email From Excel VBA"
EmailItem.HTMLBody = "Hi," & vbNewLine & vbNewLine & "This is my first email from Excel" & _
vbNewLine & vbNewLine & _
"Regards," & vbNewLine & _
"VBA Coder"
EmailItem.Send
End Sub
Upvotes: 0
Views: 28
Reputation: 166735
EmailItem.To = Str(Sheet4.Cells(1, 2))
Str
expects a numeric argument. Are you thinking of CStr()
?
Upvotes: 1