473,382 Members | 1,480 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

VB Code to create email from different outlook templates

3
HELP!
I'm using Access 2010 and Outlook

I'm attempting to create an e-mail from 1 of 5 different email templates located in a folder. (I have the templates as OFT and HTM)
(When I run the following code I get: Object Required on this specific line of code)
===================
Set MyMail = MyOutlook.CreateItemFromTemplate("C:\Users\AC94014 \Desktop\Test\ky.oft")
=================================


Set MyMail = MyOutlook.CreateItemFromTemplate("C:\Users\AC94014 \Desktop\Test\ky.oft")

If strFile <> "" Then

Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)

With MailOutLook
'.BodyFormat = olFormatRichText
.To = Me.CONTACT_EMAIL_ADDRESS
''.cc = ""
''.bcc = ""
.Subject = "Q3 - " & State & " - " & Me.ORG_NAME & " - " & Me.FileName & " - Provider Roster"

' .HTMLBody = letter
.Attachments.Add (strPath & strFile)
'.Send
.Display '
End With
Exit Sub
Sep 22 '16 #1
2 2031
PhilOfWalton
1,430 Expert 1GB
Purely a guess, but try this
Expand|Select|Wrap|Line Numbers
  1.  
  2. Set appOutLook = CreateObject("Outlook.Application")
  3.  
  4. Set MyMail = appOutlook.CreateItemFromTemplate("C:\Users\AC94014 \Desktop\Test\ky.oft")
  5.  
  6. If strFile <> "" Then
  7. Set MailOutLook = appOutLook.CreateItem(olMailItem)
  8.  
  9.  
Phil
Sep 22 '16 #2
FGuasp
3
Thank you! I had to do a little tweaking and it worked
Sep 23 '16 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Michele | last post by:
Hi, I need to send the same Email to different people. I'm using Outlook XP and VB.Net. I tryed with the following code: Dim oOutL As Outlook.Application Dim oMail As Outlook._MailItem oOutL...
2
by: John | last post by:
Hi I am trying to find the way to create an email in outlook. I am using the code given at the end. It works fine the first time but calling the code second time gives the following error; ...
0
by: JohnB | last post by:
Hi I am trying to send an email throw Outlook Object Model and i receive the error : "File or assembly name Interop.Outlook, or one of its dependencies, was not found." I add Microsoft Outlook...
2
by: Atley | last post by:
I am trying to create an application that automatically sends an email using outlook express... Has anyone done this, and if so can you point me in the right direction?
4
by: roni | last post by:
i dont like to use ocx controlx. is there new dll for vb.net that do the job ? or newer code, to send email throught outlook express.
3
by: hamster | last post by:
Hi there im writing a program that has to read email from outlook. does anyone know how? I managed to read all the subjects in my inbox but i'd like to read the 1st 1 in the inbox. here's the code...
2
by: clloyd | last post by:
I have a command button on two different forms that are exactly the same only named different. When you hit the button it creates an Outlook Email filling in the TO, Subject, and Email Text. It works...
1
by: Terry Olsen | last post by:
I need my vb app to create an email & paste in a screenshot of my app's main datagrid. I know how to create & send emails and even add attachments. But the request is to show the screenshot in the...
1
by: neovantage | last post by:
Hey, I have read an email template and sending emails through php mail function. It shows html code when i open that received email in outlook express but it shows normal content in hotmail, yahoo,...
10
by: Corwin Moyne | last post by:
Hi there. I'm a complete noob when it comes to VBA. I have some code that I got online to send an email using Outlook through Access 2010. The code works by displaying an Outlook message window, but...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.