Jump to content

Sending an outlook email with HTMLbody


Go to solution Solved by MikahS,

Recommended Posts

Posted

This is the code that I'm executing. 

$HTMLsource=FileRead('C:\Users\n811761\Desktop\Test.htm')
            $emailAddress = 'Test@Fake.com'
            $olApp = ObjCreate("Outlook.Application")
            $olMailItem = 0
            $objMail = $olApp.CreateItem($olMailItem)
            $objMail.Save
            With $objMail
                .To =($emailAddress)
                .Subject = ("Thank You for Contacting!")
                .HTMLBody = ($HTMLsource)
                .Display
            EndWith
            $oOApp = 0

The problem I'm having is that the HTML file has references to image files.

I was looking at GDIPlus, and it seems like I should be able to convert the image files into a string that I can save so the HTML becomes self contained, but I'm not sure exactly how. I've attached a copy of the HTML and its resource files. If someone could steer me in the right direction, that would be great.

test.zip

  • Solution
Posted (edited)

something like this?

#Include <GDIPlus.au3>
_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile(@SystemDir & "\DirectX\Dinput\act_rs.png")
$sCLSID = _GDIPlus_EncodersGetCLSID("BMP")
_GDIPlus_ImageSaveToFileEx($hImage, @ScriptDir & "\act_rs.bmp", $sCLSID)
_GDIPlus_ShutDown()

taken from: >link

Edited by MikahS

Snips & Scripts

  Reveal hidden contents

My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Posted

That's what I needed... I was trying to find that exactly! Much appreciated!

Posted

My pleasure! ;)

Snips & Scripts

  Reveal hidden contents

My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Posted

Or you could use my OutllokEX UDF, attach the image and reference using CID as described in the _OL_ItemCreate example.

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

I was trying to leverage your script water, but I just needed a simple send email function so I didn't want to add a whole UDF. 

I ended up finding this command:

$objMail=$olApp.CreateItemFromTemplate

and

.HTMLBody = StringReplace($objMail.HTMLBody, "%25Hyperlink%25", $strHyperlink)

and I was able to specify the template file which contained the images so I didn't need to transform the images. It also made string replacement much easier with the template file.

Posted

The big advantage of running obfuscator when compiling a script is that you can strip off any uunused functions. So the overhead of using a UDF is reduced.

But you are right: Anything that can be done using an UDF can be done directly in the script :)

My UDFs and Tutorials:

  Reveal hidden contents

 

  • Developers
Posted
  On 11/4/2014 at 6:56 PM, water said:

The big advantage of running obfuscator when compiling a script is that you can strip off any uunused functions. So the overhead of using a UDF is reduced.

But you are right: Anything that can be done using an UDF can be done directly in the script :)

Obfuscator? guess you are a couple of releases behind. ;)

Use AU3Stripper for that.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

Seems my computer is up to date but not my brain :)

My UDFs and Tutorials:

  Reveal hidden contents

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...