I can insert manually a picture into an outlook 2010 new email using "Insert picture" and the “insert link to file” feature. In the File field I enter the link: http://www.example.com/image.php?s1=song1.net & c1=composer
The link returns an image and I can see it in the body of the email.
I need to enter this URL using VBA. I wrote the code below and it does not work. When I tried to run it came with the following message: Run-time error ‘4198’: Command failed. It highlights the line that includes the link.
My code:
Sub insertHTMLFile()
Dim Insp As Inspector
Set Insp = ActiveInspector
If Insp.IsWordMail Then
Dim wordDoc As Word.Document
Set wordDoc = Insp.WordEditor
wordDoc.Application.Selection.InsertFile "http://www.example.com/image.php?s1=song1.net & c1=composer ", , False, False, False
End If
End Sub
I would appreciate it if you can show me how I can use VBA to insert the image as I did it manually. Unfortunately Outlook does not have a macro recorder which could show me the instructions how to do it.