VBA script to add HTML attachment as text in Outlook 2007

OBIS1

New Member
Joined
Oct 18, 2011
Messages
4
Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<o:p></o:p>
Our admin team currently send client documents via email. The current process is that our system automatically creates an email with the documents attached and the user then runs a macro within the email which attaches an HTML file and inserts as text to give the email a nice polished and professional look.<o:p></o:p>
<o:p></o:p>
We were using Office 2003 which allows you to manually record a macro however some users now have Office 2007 so I have to write the macro manually as the record function is no longer available. I have tried copying the VBA script however this fails with the error - Complie Error Sub or Function not defined.<o:p></o:p>
<o:p></o:p>
This was the original macro<o:p></o:p>
<o:p></o:p>
Sub addattachment()<o:p></o:p>
ChangeFileOpenDirectory "Z:\I.T Department\Call Back Email Templates\"
Selection.InsertFile FileName:="1506ONE process email.html", Range:="", _
ConfirmConversions:=False, Link:=False, Attachment:=False
End Sub
<o:p></o:p>
<o:p></o:p>
I have been given the following code to try however this just attaches the file normally and does not insert as text.<o:p></o:p>
<o:p></o:p>
Sub addattachment()<o:p></o:p>
ActiveInspector.CurrentItem.Attachments.Add "Z:\I.T Department\Call Back Email Templates\1506ONE process email.html"<o:p></o:p>
End Sub<o:p></o:p>
<o:p></o:p>
If anyone has any ideas or more information please let me know.<o:p></o:p>
<o:p></o:p>
Cheers<o:p></o:p>
<o:p></o:p>
Sean
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
The original macro will fail after SUB NAME(). This VBA was created using the Record button in Outlook 2003. As Outlook 2007 does not have this I had to paste the old script into Visual Basic under the Developer Tab in a new email.
 
Upvote 0
Sorry I don't see SUB NAME() in the code you posted.

By the way Outlook doesn't have a macro recorder in any version.
 
Upvote 0
Apologies,

It is the SUB addattachment(). This is highlighted in yellow with an arrow and the ChangeFileOpenDirectory is highlighted in blue.
 
Upvote 0
This is all that appears when I open the VBA on a machine running Outlook 2003.

Is there not a piece of code I can add to the following as this does pull through the attachment but inserts as text.

Sub addattachment()<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
ActiveInspector.CurrentItem.Attachments.Add "Z:\I.T Department\Call Back Email Templates\1506ONE process email.html"<o:p></o:p>
End Sub<o:p></o:p>
 
Upvote 0

Forum statistics

Threads
1,225,072
Messages
6,182,697
Members
453,132
Latest member
nsnodgrass73

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top