Jump to content
Jewtus

Hyperlink with arguments

Recommended Posts

Jewtus

I have a compiled tool that has a few options for command line arguments to kick off specific functions. I've tested them via the cmd line and they work great. What I'd like to do next is make it so my email notification contains a hyperlink to the file with the argument included. This is what I have for my email function that DOES work:

Func SendEmails($addAddressee,$id)
    IsOutLookOpen()
    $olApp = ObjCreate("Outlook.Application")
    $objMail = $olApp.CreateItem(0) ;$olMailItem
    With $objMail
        .Save
        .Subject = ("A form needs review - ID: "&$id)
        .HTMLBody = ('Please open the tool by clicking <a href="'&@ScriptDir&"\"&@ScriptName&'">HERE</a>.')
        $oRecipients=.Recipients
        .Display
    EndWith
    For $z=0 to UBound($addAddressee)-1
        If $addAddressee[$z]<> ''  Then
            $resolver=$oRecipients.Add($addAddressee[$z])
            $resolver.Resolve
        EndIf
    Next
EndFunc

and this works without issue but I want to make it so when they click the link, it also passes the command line arg:

.HTMLBody = ('Please open the tool by clicking <a href="'&@ScriptDir&"\"&@ScriptName&" -CMD "&$id&'">HERE</a>.')

Does anyone know how I can achieve this?

Share this post


Link to post
Share on other sites
water

I think you need to encode the spaces. Try %20 for a space.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Jewtus

Ok so I messed around with it a bit:

.HTMLBody = ('Please open the tool by clicking <a href='&StringReplace(@ScriptDir,' ','%20')&'\'&@ScriptName&'%20-CMD%20'&$id&'">HERE</a>.')

and this generates the link but when I open the link it says the file isn't found... Something like this

Cannot find the file '\\host\path\files\Test.exe -CMD 1'. Please verify the path or internet address is correct

So I tried to put quotes around the path and put the -CMD outside the quotes:

.HTMLBody = ('Please open the tool by clicking <a href="'&StringReplace(@ScriptDir,' ','%20')&'\'&@ScriptName&'"%20-EMC%20'&$id&'">HERE</a>.')

and when I do that, it just opens the EXE and doesn't pass the arg to the exe.

Edited by Jewtus
formatting

Share this post


Link to post
Share on other sites
water

I searched the web and got to the conclusion that it is not possible to call an exe and pass parameters using a link.

I'd suggest to just start the exe without parameters and then use Outlook to grab the ID from the subject line of the current mail item.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Jewtus

I'm not sure what you mean. I want the tool to operate normally, but I have a notifications section so when X action is performed, it notifies someone that they need to open the tool and go to a specific section. I was hoping to jump right to that section from the email. If I launch the tool normally, how would I go about grabbing the id from the email and passing it through to the application?

Share this post


Link to post
Share on other sites
water

When the tool is started you should

  • Check that Outlook is running
  • A mail item is active
  • the mail item has a subject of format "A form needs review - ID: "

If this is True then grab the ID from the subject and jump to the section needed. Else run the program normally.
This approach only works when the mail is being opened by Outlook.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Jewtus

hmmm seems it could leave room for a lot of potential errors... I did figure out a simple solution that does seem to work though... Build a bat and link to the bat file:

Func SendEmails($addAddressee,$id)
    IsOutLookOpen()
    $olApp = ObjCreate("Outlook.Application")

    ;Build Launcher
    If FileExists(@ScriptDir&"\CMD\")=0 then DirCreate(@ScriptDir&"\CMD\")
    $cmdFile=@ScriptDir&"\CMD\"&$id&@MON&@MDAY&@YEAR&@HOUR&@MIN&@SEC&".bat"
    FileWrite($cmdFile,'"'&@ScriptDir&"\"&@ScriptName&'" -CMD '&$id)

    $objMail = $olApp.CreateItem(0) ;$olMailItem
    With $objMail
        .Save
        .Subject = ("A new form needs review - Project ID: "&$id)
        .HTMLBody = ('Please open the tool by clicking <a href="'&$cmdFile&'">HERE</a>.')
        $oRecipients=.Recipients
        .Display
    EndWith
    For $z=0 to UBound($addAddressee)-1
        If $addAddressee[$z]<> ''  Then
            $resolver=$oRecipients.Add($addAddressee[$z])
            $resolver.Resolve
        EndIf
    Next
EndFunc

 

Edited by Jewtus

Share this post


Link to post
Share on other sites
water

But this only works when the bat file is created on the recipients machine.
But why would you create a mail then?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Jewtus

The tool is actually on a shared network dir so everyone is using the same folder structure. The mail is because no one will actually keep an eye on it because users suck. They want the system to send emails if anything ever changed and I told them they would get 20-30 notifications an hour if they did that so they settled to me just sending a summary email telling them to check.

 

The launching the bat is just a way of accommodating users who are lame and don't want to do their job or read anything.

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

  • Similar Content

    • water
      By water
      Extensive library to control and manipulate Microsoft Outlook.
      Theads: Development - General Help & Support - Example Scripts - Wiki
      BTW: If you like this UDF please click the "I like this" button. This tells me where to next put my development effort

      KNOWN BUGS (last changed: 2018-09-01)
      None
    • Gowrisankar
      By Gowrisankar
      Dear members of the forum,
      I need to open the attachments from mails without downloading them. Is it possible using OutlookEx UDF ?
    • Gowrisankar
      By Gowrisankar
      Dear members,
      I'm trying to get the attachments from mails using OutlookEx UDF and then save them in a particular location.
      The UDF considers even the signature images and other images in the mail body as attachments, and saves it in the folder I point. I want only the proper attachment documents to be saved.
      Requesting the guidance of the forum members.
       
       
      Thanks and regards,
      Gowrisankar R.
    • Gowrisankar
      By Gowrisankar
      Dear members,
      I'm trying to move unread mails from Inbox to a different folder using OutlookEx UDF.
      But its not working for me. I'm not sure what mistake I do.
      I get the error code 6 when the following is executed. From the UDF it is observed that  "No or an invalid item has been specified".
      Note : The UDF version is 1.3.3.1. AutoIt version (v3.3.14.2).
      #include <OutlookEX.au3> Global $oOutlook = _OL_Open() If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended) Global $aOL_Item = _OL_ItemFind($oOutlook, "*\Inbox", $olMail, "[UnRead]=True", "", "", "Subject", "", 1) If $aOL_Item[0][0] = 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemMove Example Script", "Could not find a task item in folder 'Outlook-UDF-Test\SourceFolder\Tasks'. @error = " & @error) _ArrayDisplay($aOL_Item, "OutlookEX UDF: _OL_ItemFind Example Script - Unread mails") _OL_ItemMove($oOutlook, $aOL_Item[1][0], Default, "*\Outlook-UDF-Test\TargetFolder\Mail") If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemMove Example Script", "Error moving specified task. @error = " & @error) Any help is deeply appreciated. Thanks in advance.
      Thanks and regards,
      Gowrisankar R.
    • nacerbaaziz
      By nacerbaaziz
      Hi dear
      With this script you can print Unicode text in the CMD screen
      the script is  easy to use
      just you  write the text that contains Unicode in the first input
      and the script automatically reflect the code in the second input
       you can copy the text to the clipboard
      or you can try printing the text in the CMD window
      I apologize to everyone for colors and shape if not appropriate
      I'm a blind man and I do not see
      Thank you for your understanding
      Greetings to all of youCmdUtM.au3
×