Lights_On

‘Mailto’ with attachment

11 posts in this topic

Hi All,

I have the below code:

 

ShellExecute("mailto:" & $TheEmailAddress & "?subject=" & $Subject & "&importance=high" & "&body=" & $Message & "&attachment=" & $Attachment, "", @TempDir)

 

This works fine other than I wish to be able to:

  1. Add an attachment (the ‘&attachment=’ does not work)

  2. Set the priority (the ‘&priority=’ does not work)

  3. Have the body of the text not remove the default signature.
    1. Ideally have the body of the text as a separate template or similar.

 

I am aware I can use solutions that send the email quietly in the background and I do indeed use these.  But for this purpose I need for the email to be opened so I can make amendments before sending the email if required.

 

Thank you in advance for any suggestions.

Share this post


Link to post
Share on other sites



Which mail client do you run?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Hi Water,

 

Thank you for your time.

 

I use Outlook 2010.

Share this post


Link to post
Share on other sites

Then you could use my OutlookEX UDF to do all the things you want (and more) in the background.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Thank you - I saw this and it is excellent - however does this not only do things "in the background"?  I seek to have the email in the foreground so the I can make amendments if desired.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

The UDF supports processing in the back- and foreground - as you like.
For example:

#include <OutlookEX.au3>
Global $oItem
Global $oOutlook = _OL_Open()
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended)
; Create the item
$oItem = _OL_ItemCreate($oOutlook, $olMailItem, "*", "", "Subject=TestMail", "BodyFormat=" & $olFormatHTML)
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating the mail item. @error = " & @error & ", @extended = " & @extended)
; Add an attachments
$oItem = _OL_ItemAttachmentAdd($oOutlook, $oItem, Default, @ScriptDir & "\The_Outlook.jpg")
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error adding an attachment to the mail item. @error = "  & @error & ", @extended = " & @extended)
; Display the mail item
$oItem.Display

 

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Wonderful - thank you.  I shall try that out. it appears i had overlooked the part that shows the item:

 

; Display the mail item
$oItem.Display

 

Edited by Lights_On

Share this post


Link to post
Share on other sites

Hi Water,

 

Thank you again - this is working great.

 

A quick question that may seem obvious but just wanted to seek clarity.

 

Should I always 'OL_Open)' but only 'OL_close()' if i want to close Outlook?  So should I check if Outlook is open first and then make a choice as to how I use 'OL_close()'?

 

I seek to never close Outlook but I will need to open it if its not running as I don't want the action to happen in the background.

 

I read the below but still had a few '???' around my question:

" Remarks: If Outlook was already running when _OL_Open was called you have to use flag $bForceClose to close Outlook. 
  If Outlook was already running when _OL_Open was called @extended is set to 1 to indicate this  "

 

I hope my question is clear?

 

Thank you in advance.

Share this post


Link to post
Share on other sites

1) Outlook has been started by the user before
When you run _OL_Open the UDF attaches to the already running instance and sets @extended = 1 to let you know that Outlloks was started by the user.
When you run _OL_Close parameter $bForceClose set to False then the script detaches from Outlook but Outlooks remains up and running.
When you run _OL_Close parameter $bForceClose set to True then the script detaches from Outlook and forcefully shuts down Outlook as well.

2) Outlook has not been started by the user before
_OL_Open starts Outlook and attaches the script to this newly started instance.
_OL_Close independant of parameter $bForceClose  detaches the script from Outlook and shuts Outlook down.

Conclusion:
Most of the time a simple _OL_Open at the start of your script and _OL_Close at the end is sufficient.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#10 ·  Posted

Perfect - completely understood. Thank you. 

Share this post


Link to post
Share on other sites

#11 ·  Posted

:) 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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