Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Using .fot outlook template to send email from access

Avatar of Simon_ICSNET_UK
Simon_ICSNET_UK asked on
Microsoft Access
29 Comments1 Solution2499 ViewsLast Modified:
Hi all,

I am attempting to use the code shown below to send email directly from a MS Access form using VBA behind a button although I keep getting a runtime 13 error when stepping through and get to the line Set MyMail = MyOutlook.CreateItemFromTemplate("c:\emailtemplates\einvoice.oft")

I have the following references enabled ...
Visual Basic for Applications
MS Access 14.0 Object Libary
MS Outlook 14.0 Object Libary
OLE Automation
MS Office 14,0 Access database engine object libary
MS Internet Controls
MS Outlook View Control
MS ActiveX data objects 6.0 Libary


Public Function SendMyEmail()
Dim db As DAO.Database
Dim MyOutlook As Outlook.Application
Dim MyMail As Outlook.MailItem
Set MyOutlook = New Outlook.Application
Set db = CurrentDb()
Set MyMail = MyOutlook.CreateItemFromTemplate("c:\emailtemplateseinvoice.oft")
MyMail.SentOnBehalfOfName = "a@a.com"
MyMail.To = Form_frmTemplate.txtTo.Value
MyMail.CC = Form_frmTemplate.txtE_CC.Value
MyMail.Subject = Form_frmTemplate.txtE_sub.Value
MyMail.OriginatorDeliveryReportRequested = False
MyMail.ReadReceiptRequested = False
MyMail.HTMLBody = Replace(MyMail.HTMLBody, "Variable Field", Form_frmTemplate.txtClaim)
MyMail.Display
'MyMail.BodyFormat = olFormatRichText
'MyMail.Send
End Function
ASKER CERTIFIED SOLUTION
Avatar of DavidT543
DavidT543Flag of United Kingdom of Great Britain and Northern Ireland image

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 29 Comments.
See Answers