DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

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

questorfla

  • Fighting Slime all the Time
  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 570
Trigger the Send function in a new email from command line
« on: September 04, 2016, 12:38 AM »
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

  • what am I doing in this handbasket?
  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 888
    • Participated in NANY Challenge Once
Re: Trigger the Send function in a new email from command line
« Reply #1 on: September 04, 2016, 01:45 AM »
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

  • Fighting Slime all the Time
  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 570
Re: Trigger the Send function in a new email from command line
« Reply #2 on: September 04, 2016, 05: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,649
    • Participated in NANY Challenge Eleven Times
    • Coding Snacks
    • Linux User
    • Hardware Hacker
Re: Trigger the Send function in a new email from command line
« Reply #3 on: September 04, 2016, 08: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:
/Ton
Ath's software collection, Quote: "A problem well stated is a problem half-solved." (Charles Kettering)

questorfla

  • Fighting Slime all the Time
  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 570
Re: Trigger the Send function in a new email from command line
« Reply #4 on: September 04, 2016, 10: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, 11:28 PM by questorfla »

4wd

  • Pedantic Old Bastard
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,652
    • Coding Snacks
Re: Trigger the Send function in a new email from command line
« Reply #5 on: September 05, 2016, 01:30 AM »
Code: ( powershell)
param (
  [string]$toaddr = $(throw "EmailArc.ps1 <email address> <file|folder>"),
  [string]$file = $(throw "EmailArc.ps1 <email address> <file|folder>")
)

$arcfile = $env:temp + '\' + ([System.IO.Path]::GetFileNameWithoutExtension($file)) + '.zip'

if (Test-Path $arcfile) {
#  Write-Host 'Updating archive'
  Compress-Archive -Path $file -Update -DestinationPath $arcfile -CompressionLevel Optimal | Out-Null
} else {
#  Write-Host 'Creating archive'
  Compress-Archive -Path $file -DestinationPath $arcfile -CompressionLevel Optimal | Out-Null
}

$newarc = $arcfile -replace '(.*)(\.zip$)', '$1zip'
Move-Item -Path $arcfile -Destination $newarc

$ol = New-Object -comObject Outlook.Application 
$mail = $ol.CreateItem(0) 
$Mail.Recipients.Add($toaddr) 
$Mail.Subject = (Split-Path $file -Leaf)
$Mail.Body = "Archive containing: " + (Split-Path $file -Leaf) + "`n`nRename *zip to *.zip"
$Mail.Attachments.Add($newarc)
$Mail.Send() 

Start-Sleep -Seconds 1

Remove-Item $newarc
"I will not follow where the path may lead, but I will go where there is no path, and I will leave a trail." - Muriel Strode, 1903

Shades

  • Member
  • Joined in 2006
  • **
  • Posts: 2,954
Re: Trigger the Send function in a new email from command line
« Reply #6 on: September 05, 2016, 05: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.
The easy path is usually downhill...

x16wda

  • what am I doing in this handbasket?
  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 888
    • Participated in NANY Challenge Once
Re: Trigger the Send function in a new email from command line
« Reply #7 on: September 05, 2016, 06: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

Original address: https://www.donationcoder.com/forum/index.php?topic=42982.0