topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday March 28, 2024, 7:28 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Trigger the Send function in a new email from command line  (Read 5658 times)

questorfla

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 570
  • Fighting Slime all the Time
    • View Profile
    • Donate to Member
Trigger the Send function in a new email from command line
« on: September 03, 2016, 07:38 PM »
This is either so simple and right in front of me that i can;t see it or doesn't exist as needed.

In a batch script that uses the Outlook.exe ipm.note parameter, once the email is loaded and ready to send, how can i trigger the send function from within the script.  Everything works perfectly except for that last item.

I have a vbs version that CAN trigger the send (but so far cannot add the zipped attachment properly) which makes me think that there must be some method of activating SEND from the command line.  Currently, the completed email sits there waiting for me to press the Send button 

This was a handy "feature" during testing so I could see and correct errors and configurations But now that it works as desired I want it to immediately "Send" like the VBS version does.
Could I call a "SEND_EMAIL.VBS" script from inside the batch as a final command ? 

I am still trying to rewrite the whole thing as VBS but ran into issues getting the correct zip file attached to the pre-addressed email.  I have not given up on that yet though and it may be the best way.

x16wda

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 888
  • what am I doing in this handbasket?
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: Trigger the Send function in a new email from command line
« Reply #1 on: September 03, 2016, 08:45 PM »
I always use blat.exe to send emails from the command line. Much faster and more straightforward. The site used to be www.blat.net which will lead you to an older but still perfectly useable version on sourceforge, but the distribution of newer releases these days is from a yahoo group named blat-Discussion. Most recent update was June 16.
vi vi vi - editor of the beast

questorfla

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 570
  • Fighting Slime all the Time
    • View Profile
    • Donate to Member
Re: Trigger the Send function in a new email from command line
« Reply #2 on: September 04, 2016, 12:02 AM »
Thanks X16.  That is usually my problem in that i get so focused on doing it one way that i fail to look at complete alternatives.

I added an extension to Chrome 'URL to Clipboard' that can load the URL's for every open tab onto the clipboard.  Then i found another tool that can load the contents of clipboard to a Word Doc which i was able to set a hot key to activate.

So I jumped for both of them only to find that my 'preferred' method of storage (emailing it to myself) would not work :(.    The problem is I cannot get the word doc. attached to an email. 

This is now sort of a "grudge match" that i am determined to make work even if I never use it again.
For what it is worth, the tools to read and use the contents of clipboard came from an obscure site named at this link:   http://vb.mvps.org/tools/ConClip/.  There are a number of useful things that can be done with the pair in a very straightforward manner.

Such as getclip>URLs.doc to put the URLs in the clipboard into a word.doc


Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,612
    • View Profile
    • Donate to Member
Re: Trigger the Send function in a new email from command line
« Reply #3 on: September 04, 2016, 03:12 AM »
May I suggest my WinSendKeys tool I wrote for a fellow-DCer, published on my dcmembers.com page?
It's designed for your task, and then some  :up:

questorfla

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 570
  • Fighting Slime all the Time
    • View Profile
    • Donate to Member
Re: Trigger the Send function in a new email from command line
« Reply #4 on: September 04, 2016, 05:24 PM »
Thanks ATH.  That may do the trick  I was able to make things a little slicker by sending the links in clipboard direct to "urls.html" and drop that into an email without getting any complaints from outlook so i can probably remove the 7zip portion on the script  If winsend can "push the button" for "Lazy Old Me" i may get this down to a single hotkey start to finish.  :)

Mind if i ask what the proper way to access the send button with it?  Can i in some way assign it a 'name" to access with your app?  I read thoigh, (but not closely :( )  the instructions.  From your description of what it did for split_e should work for me too,
I have my script down to 2 lines now  If the third one is the "charm" that send the email out.  .....:)  Happy Me.

OK, I am one step closer.  There are actually TWO key combos to emulate SEND.  One is Ctrl+enter  The other is ALT+S.  Never knew about either and was surprised how easily i found them.  Gotta save that URL :) .   
« Last Edit: September 04, 2016, 06:28 PM by questorfla »

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,641
    • View Profile
    • Donate to Member
Re: Trigger the Send function in a new email from command line
« Reply #5 on: September 04, 2016, 08:30 PM »
Code: PowerShell [Select]
  1. param (
  2.   [string]$toaddr = $(throw "EmailArc.ps1 <email address> <file|folder>"),
  3.   [string]$file = $(throw "EmailArc.ps1 <email address> <file|folder>")
  4. )
  5.  
  6. $arcfile = $env:temp + '\' + ([System.IO.Path]::GetFileNameWithoutExtension($file)) + '.zip'
  7.  
  8. if (Test-Path $arcfile) {
  9. #  Write-Host 'Updating archive'
  10.   Compress-Archive -Path $file -Update -DestinationPath $arcfile -CompressionLevel Optimal | Out-Null
  11. } else {
  12. #  Write-Host 'Creating archive'
  13.   Compress-Archive -Path $file -DestinationPath $arcfile -CompressionLevel Optimal | Out-Null
  14. }
  15.  
  16. $newarc = $arcfile -replace '(.*)(\.zip$)', '$1zip'
  17. Move-Item -Path $arcfile -Destination $newarc
  18.  
  19. $ol = New-Object -comObject Outlook.Application
  20. $mail = $ol.CreateItem(0)
  21. $Mail.Recipients.Add($toaddr)
  22. $Mail.Subject = (Split-Path $file -Leaf)
  23. $Mail.Body = "Archive containing: " + (Split-Path $file -Leaf) + "`n`nRename *zip to *.zip"
  24. $Mail.Attachments.Add($newarc)
  25. $Mail.Send()
  26.  
  27. Start-Sleep -Seconds 1
  28.  
  29. Remove-Item $newarc

Shades

  • Member
  • Joined in 2006
  • **
  • Posts: 2,922
    • View Profile
    • Donate to Member
Re: Trigger the Send function in a new email from command line
« Reply #6 on: September 05, 2016, 12:25 AM »
While blat offers their command-line mailer for free (non-commercial use only), I found it to behave problematic in an automatized process, where I generate a custom mail message with attachment. Then I found CMail (commercial use allowed) and that worked much more reliable in my scenario. Perhaps this is of some use to you too.

x16wda

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 888
  • what am I doing in this handbasket?
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: Trigger the Send function in a new email from command line
« Reply #7 on: September 05, 2016, 01:51 PM »
Thanks for the link Shades - I haven't needed anything other than what Blat offers yet, but I'll need to play with CMail now since it has TLS support. Always good to have more tools in the toolbox!
vi vi vi - editor of the beast