'Why replyEmail.AddBusinessCard (contact) in Outlook Macro get Expect Object error?
I have to make a macro in outlook that enable to respond an email with a template and in this template, attach a contact vcard (as attachment).
Here is the code:
Sub ResponderConAttachment()
Dim origEmail As MailItem
Dim replyEmail As MailItem
Dim contact As ContactItem
Dim myNamespace As Outlook.NameSpace
Dim myContacts As Outlook.Items
Set myNamespace = Application.GetNamespace("MAPI")
Set myContacts = myNamespace.GetDefaultFolder(olFolderContacts).Items
Set origEmail = Application.ActiveInspector.CurrentItem
Set replyEmail = Application.CreateItemFromTemplate("C:\Users\diego\AppData\Roaming\Microsoft\Templates\RespuestaContacto.oft")
Set contact = myContacts.Item(15)
replyEmail.AddBusinessCard (contact) - ***This line gives an error saying is expecting an object.***
replyEmail.To = origEmail.To
replyEmail.CC = origEmail.CC
replyEmail.Subject = origEmail.Subject
replyEmail.HTMLBody = replyEmail.HTMLBody & origEmail.Reply.HTMLBody
replyEmail.Display
End Sub
Thanks for any help.
Solution 1:[1]
Documentation may indicate brackets.
Remove them
replyEmail.AddBusinessCard contact
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | niton |
