Solved

How to pick the HTML code of an Outlook model with VBA without creating a new template.

Posted on 2009-04-15
24
583 Views
Last Modified: 2013-11-27
I am using a VBA function in Access that generates emails from an .oft outlook model with the code below. Since it forces the user to prompt the Outlook safe msg box "..is trying to access the address book for N minutes...", I would like to to this:
1. pick the HTML code of the model without having to create an item from template;
2. create a new item (in this way I am not asked to prompt the safety msg box)
3. put the code in the new item.
Can you suggest an useful code to do this? Thanx.
....

    Set olkApp = CreateObject("Outlook.application")

    Set olkMsg = olkApp.CreateItemFromTemplate(oModello)

....

Open in new window

0
Comment
Question by:Sar1973
  • 11
  • 11
24 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
Comment Utility
It seems like a similar outlook security pop-up to the one that is displayed when you are trying to send an email via VBA.

Contact the people who make this product:
http://www.contextmagic.com/express-clickyes/

Here:
http://www.contextmagic.com/contact.htm

... and ask them if they have a way to similarly dissable this message.

;-)

JeffCoachman
0
 
LVL 9

Author Comment

by:Sar1973
Comment Utility
Jeff, thanx for your answer but I want to try another solution. With VBA, I want to:
1. set the .oft file I have in a folder of my PC
2. pick its HTML code
3. create a new Outlook item
4. set its HTML code like 2.
In this way the warning message should not appear; I do not want to install a specific software.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
Comment Utility
OK

Good luck.

JeffCoachman
0
 
LVL 9

Author Comment

by:Sar1973
Comment Utility
Then, do you know something like below?
Dim myFile as file

Dim olkApp as Application

Dim olkMsg as ...

Dim myHTML as string

set myFile="C:\Model.oft"

myHTML=myFile.HTMLBody

Set olkApp = CreateObject("Outlook.application")

    Set olkMsg = olkApp.CreateItem(0)

With olkMsg

.HTML=myHTML

....

Open in new window

0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
Comment Utility
My knowledge of this subject only goes as far as using MS Access and VBA automation to send Emails from Outlook.
In that capacity is where I recognized the similarity of your alert with the common alert in Access-Outlook email automation.

Any other Outlook specific code is ouside of my "Sphere of Knowledge".
;-)

JeffCoachman
0
 
LVL 9

Author Comment

by:Sar1973
Comment Utility
Didn't know that picking HTML code from a file (.htm, .omsg or .oft) was so difficult.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
Comment Utility
Sar1973,

<Didn't know that picking HTML code from a file (.htm, .omsg or .oft) was so difficult.>
It's not, but that was not your question.

Your exact question was:
<How to pick the HTML code of an Outlook model with VBA without creating a new template.>
Then:
<pick the HTML code of the model without having to create an item from template;>

In both cases you clearly state "Object Model", not "File".

Please clarify.

0
 
LVL 9

Author Comment

by:Sar1973
Comment Utility
Yes, but it is definitely a file located in my PC, like "C:\Model.oft". It is then defined as a model.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
Comment Utility
Then call it a File.
I have no idea of what a "defined as a model" means.
And the fact that you simply want to extract the HTML from it, renders it's status as a "Model" meaningless in this context.
;-)

Ok, so can you post a sample of this "File", and I'll take a look?

Jeff
0
 
LVL 9

Author Comment

by:Sar1973
Comment Utility
It is an Outlook model. You can do this: create a new Outlook item and write whatever you want in it and/or attach a picture, then save is as Outlook model with a name such "C:\Model.oft". You'll have the file I am interested in picking its HTML code
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
Comment Utility
No Time.

Can you just post a sample file?
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 9

Author Comment

by:Sar1973
Comment Utility
Here you got it; since EE does not accept the .oft format, neither if it is in a .zip archive, you will have to rename the fiel I have included in the .zip file adding the .oft extension ("The extension of one or more files in the archive is not in the list of allowed extensions").
Modello.zip
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
Comment Utility
The File appears to be "Binary", not text.

Hence, there is no strict HTML that can be easilly extracted from it.
Here is the only really Human Readable portion of the file:
'-----Start-----
Alessandro Sardella                                             >    LZFu«¢Õ"
 rcpg1252Chtml10ÿ÷
¬¤ä¬ÿ PVU²5Q ch
Àset2 ÛÃ53FÇ0? ª4ÆVd pa¬·Cï      ÷;x052 `c P       d36`É ¥4 *\²g@3 <!DO CTYPE HT ML PUBLI C "-//W3"C! DTD 4.É`Tr rti @á! EN">C·`ó
£#l19p "#^Pñ%ÀEAD#]ñ$(o%D6ð<META}  0      ðt="àå #6"0.°,Ñ+280" ¬¬=G# ERATOR#]z4+1/'O!)ß5Á`<BODY#]Á1Og96pDIV÷#Pà !   5Å`"S645¯6²$Ì48pÀFONT f Ð-ðÕ5  z-ð25:_²Ð08ó8'S8PAN+  `=3@970637 -2804Ð095x)6£Th  Bth}el<4Out0ok b I w?0B`@ikng ó `t.4\P/À>Â×@"@§8þ551/:2Gÿ6®À@§
¢H8
¬$Ì@0ß/±5lH?1ö:/2¯!.7/²%ï$7}U0                                                              This is the Outlook model I was talikng about.

'-----end-----

JeffCoachman
0
 
LVL 9

Author Comment

by:Sar1973
Comment Utility
In fact, you have to extract it and then rename it to "Modello.oft" in explorer: you'll then see the envelope icon which means you can open it with Outlook. Of you'll launch it, you'll have a new Outlook message. I do not understand why and how you get this code; the file is not binary neither text.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
Comment Utility
Sar1973,

Actually, the file is binary.

When it is named XXX.oft, it is indeed an Outook Message.
And you can open it as an item in Outlook, and read the "Text".

But the file itself is in a Binary format.
When you open the file in Outlook, Outlook translates the Binary data into a "Readable" message.
;-)

Again, there appears to be no strick HTML to extract from the file.
:-(

Jeff
0
 
LVL 9

Author Comment

by:Sar1973
Comment Utility
Then how is it possible that the code below works, when I use .oft models and I insert specific references (es. "Dear Jeff" at the place of "«Destinatario»")? The only exception is, of course, the Outlook alert.
In other words, I should save my model in a format that allows me to pick its HTML code and then put in in the new item I have created with the "With" action.
    Dim olkApp As Object, olkMsg As Object

    Dim oHTML0 As String, oHTML As String
 

    Set olkApp = CreateObject("Outlook.application")

    Set olkMsg = olkApp.CreateItemFromTemplate(oModello)

    oHTML = Replace(olkMsg.HTMLBody, "«Destinatario»", oDestinatario, , , vbTextCompare)
 

    With olkMsg

            .ReadReceiptRequested = True

            .To = "myAddress@email.it"

            .HTMLBody = oHTML

            .Send

    End With
 

    Set olkApp = Nothing

    Set olkMsg = Nothing

Open in new window

0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
Comment Utility
The code you posted "Creates" the message.
After the message is created, it is stored as Binary Data.

Try it yourself, open the file with notepad and tell me if you seen any HTML.

If your ultimate goal is to avoid the message, I am not sure if this would work anyway.
I use this to bypass the message, and have had no problems since:
http://www.contextmagic.com/express-clickyes/

;-)

JeffCoachman
0
 
LVL 9

Author Comment

by:Sar1973
Comment Utility
A solution could be to save the .oft message in HTML format and then pick its code and put it in a new Outlook item, but I'm not sure that it would keep the originale format.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
Comment Utility
Did you investigate the link I posted?
0
 
LVL 9

Author Comment

by:Sar1973
Comment Utility
Yes, but as I said before I do not want to buy any software: I want to find a trick and solve my problem.
If you cannot help or you think it's impossible, I'll cloese the question or ask another expert.
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 125 total points
Comment Utility
<I do not want to buy any software:>
...The basic version is free.

The final disposition of this question is in your hands
0
 
LVL 9

Author Closing Comment

by:Sar1973
Comment Utility
-
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Outlook Free & Paid Tools
This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now