Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 618
  • Last Modified:

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

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
Sar1973
Asked:
Sar1973
  • 11
  • 11
1 Solution
 
Jeffrey CoachmanMIS LiasonCommented:
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
 
Sar1973Author Commented:
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
 
Jeffrey CoachmanMIS LiasonCommented:
OK

Good luck.

JeffCoachman
0
Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

 
Sar1973Author Commented:
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
 
Jeffrey CoachmanMIS LiasonCommented:
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
 
Sar1973Author Commented:
Didn't know that picking HTML code from a file (.htm, .omsg or .oft) was so difficult.
0
 
Jeffrey CoachmanMIS LiasonCommented:
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
 
Sar1973Author Commented:
Yes, but it is definitely a file located in my PC, like "C:\Model.oft". It is then defined as a model.
0
 
Jeffrey CoachmanMIS LiasonCommented:
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
 
Sar1973Author Commented:
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
 
Jeffrey CoachmanMIS LiasonCommented:
No Time.

Can you just post a sample file?
0
 
Sar1973Author Commented:
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
 
Jeffrey CoachmanMIS LiasonCommented:
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
 
Sar1973Author Commented:
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
 
Jeffrey CoachmanMIS LiasonCommented:
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
 
Sar1973Author Commented:
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
 
Jeffrey CoachmanMIS LiasonCommented:
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
 
Sar1973Author Commented:
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
 
Jeffrey CoachmanMIS LiasonCommented:
Did you investigate the link I posted?
0
 
Sar1973Author Commented:
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
 
Jeffrey CoachmanMIS LiasonCommented:
<I do not want to buy any software:>
...The basic version is free.

The final disposition of this question is in your hands
0
 
Sar1973Author Commented:
-
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

  • 11
  • 11
Tackle projects and never again get stuck behind a technical roadblock.
Join Now