• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Launching mailto from Photoshop

Participant ,
Dec 03, 2015 Dec 03, 2015

Copy link to clipboard

Copied

Is this at all possible? Either when a user presses a button or just getting the script to do it automatically? Would love to be able to do this with recipient address, subject and message.

TOPICS
Actions and scripting

Views

1.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Enthusiast ,
Dec 03, 2015 Dec 03, 2015

Copy link to clipboard

Copied

In general if you can "launch an URL" then a "mailto:name@domain.com?subject=title&body=body" _should_ open default mail app with that address and title/body prefilled. I have never tried this from inside a .jsx script, but from a HTML panel CSInterface.openURLInDefaultBrowser(url) should do it.

Note that it's not 100%, user/OS needs to have a mail client and an account ready.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 03, 2015 Dec 03, 2015

Copy link to clipboard

Copied

Yup, you are right! This launches a mailto in my default app:

function openURL(url) {

  var fname = "shortcut.url";

  var shortcut = new File(Folder.temp + '/' + fname);

  shortcut.open('w');

  shortcut.writeln('[InternetShortcut]');

  shortcut.writeln('URL=' + url);

  shortcut.writeln();

  shortcut.close();

  shortcut.execute();

};

openURL('mailto:name@domain.com?subject=title&body=body')

Only annoying thing is, it also opens safari, which then becomes the forefront window instead of Outlook.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Dec 03, 2015 Dec 03, 2015

Copy link to clipboard

Copied

You could try using vb script

VBScript:-

Dim strTo, strSubject

Dim objoutlookApp, objmessage

strTo = Wscript.Arguments.Item(0)

strSubject = Wscript.Arguments.Item(1)

strMessage = Wscript.Arguments.Item(2)

Set objoutlookApp = CreateObject("Outlook.Application")

Set objmessage = objoutlookApp.CreateItem(olMailItem)

objmessage.TO = strTo

objmessage.Subject = strSubject

objmessage.HTMLBody = strMessage

objmessage.display

set objmessage = Nothing

set objoutlookApp = Nothing

wscript.quit

Javascript:-

#target photoshop;

//path to vbs script

var cmd = "e:/vbs/outlook.vbs ";

var To =  "supermerlin@wizard.com";

var Subject = "Subject Line";

var Message = "Outlook Message";

cmd += " \"" + To + "\" \"" + Subject + "\" \"" + Message + "\"";

app.system(cmd);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 03, 2015 Dec 03, 2015

Copy link to clipboard

Copied

Thanks for this, although I am on a Mac so not sure if it would work? I tried it out by saving the VBScript as a .vbs file and then linking that to the Javascript in EST and it just printed 'Result 32256' in the console.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Dec 03, 2015 Dec 03, 2015

Copy link to clipboard

Copied

Ah, sorry VB is Windows only. You might be able to do something simular with AppleScript?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 03, 2015 Dec 03, 2015

Copy link to clipboard

Copied

LATEST

Good idea. I haven't really used AppleScript much, but that'll probably let me just launch a new message in Outlook directly rather than having to do it by opening a mailto URL. Will look into it - thanks!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 03, 2015 Dec 03, 2015

Copy link to clipboard

Copied

I use windows am an old f a r t...  I wrote one for myself to launch what old men use Thunderbird  a cheep drunk I am and still use DOS bat files. send email with the document I working on attached.

/* ==========================================================

// 2014  John J. McAssey (JJMack)

// ======================================================= */

// This script is supplied as is. It is provided as freeware.

// The author accepts no liability for any problems arising from its use

/* Help Category note tag menu can be used to place script in automate menu

<javascriptresource>

<about>$$$/JavaScripts/email/About=JJMack's email .^r^rCopyright 2014 Mouseprints.^r^rScript email active document if saved</about>

<category>JJMack's Script</category>

</javascriptresource>

*/

// enable double-clicking from Mac Finder or Windows Explorer

#target photoshop // this command only works in Photoshop CS2 and higher

// bring application forward for double-click events

app.bringToFront();

// ensure at least one document open

if (!documents.length) alert('There are no documents open.', 'No Document');

else {

  // declare Global variables

  main(); // at least one document exists proceed

  }

///////////////////////////////////////////////////////////////////////////////

//                            main function                                  //

///////////////////////////////////////////////////////////////////////////////

function main() {

  // declare local variables

  var orig_ruler_units = app.preferences.rulerUnits;

  app.preferences.rulerUnits = Units.PIXELS; // Set the ruler units to PIXELS

  try {code();}

  catch(e) {alert(e + ': on line ' + e.line, 'Script Error', true);} // display error message if something goes wrong

  app.preferences.rulerUnits = orig_ruler_units; // Reset units to original settings

}

///////////////////////////////////////////////////////////////////////////////

//                           main function end                               //

///////////////////////////////////////////////////////////////////////////////

function code() {

  var to="";

  //var to="jjmacks@hotmail.com";        // Bypass prompt and send home

  var cc="";

  var cc="jjmacks@hotmail.com";        // Copy Myself

  var att = "";                        // declare attachment var                      

  try {att=decodeURI(app.activeDocument.fullName);}

  catch(e) {alert("Document " + app.activeDocument.name + " needs to be saved"); return;}

  if (!app.activeDocument.saved) {alert("Document " + app.activeDocument.name + " needs to be saved"); return;}

 

  var testatt = new File(att);                                                         // Test if backing file still exists

  if(testatt.exists){                                                                       // convert full file name and path to windows standard form

  att = att.replace("/","");                                                              // Strip off leading "/" or the one after the leading "~"

  if (att.substr(0,1)== "~" ) {att=att.replace("~", $.getenv("USERPROFILE") +"\\");}      // user space

  else {att = att.replace("/",":\\");}                                                   // Device root :\\

  while (att.indexOf("/")!=-1 ) { att = att.replace("/","\\"); }                 // Replace "/" with "\" need two to get one

  if (to=="") {to=prompt("Enter email address",to);}                           // Prompt for email address if no default

  if (to!="" && to!=null) {emailer(to,cc,att);}                                       // If addressed emails current document backing file

  }

  else{alert('File = "' + att +'" not found');}

}

///////////////////////////////////////////////////////////////////////////////

//                                emailer  function                          //

///////////////////////////////////////////////////////////////////////////////

function emailer(to,cc,file){

  var pgm = "C:\\Program Files (x86)\\Mozilla Thunderbird\\thunderbird.exe";  // Hard coded need to be correct

  var mailer = new File(pgm);

  if(!mailer.exists){alert("Unable to find Thunderbird\rYou will need to modify Emailer.jsx\rand correct the path"); return; }

  //thunderbird -compose "to='john@example.com,kathy@example.com',cc='britney@example.com',subject='dinner',body='How about dinner tonight?',attachment='C:\temp\info.doc,C:\temp\food.doc'"

  var option ="";

  option += " -compose";

  option += ' "';

  option += "to='"

  option += to;

  option += "'";

  if(cc!="") {

  option += ",cc='"

  option += cc;

  option += "'";

  }

  option += ",subject='" ;

  option +=  "The file you requested" ;

  option += "'";

  option += ",body='";

  option +=  file ;

  option += "'";

  option += ",attachment='";

  option +=  file ;

  var file2 = "E:\\My Files\\Pictures\\JJMack.png";

  option +=  "," + file2 ;

  option += "'";

  option +='"';

  //alert('app.system("CMD /Q /C Start "Thunderbird" /B /MIN "' + pgm + '" '  + option);

  //app.system('CMD /Q /C Start "Thunderbird" /B /MIN "' + pgm + '" '  + option );

  //alert('app.system(Start "Thunderbird" /B /MIN "' + pgm + '" '  + option);

  app.system('Start "Thunderbird" /B /MIN "' + pgm + '" '  + option );

/*

  var batch_file = new File(Folder.temp + "/send_email.bat");

  batch_file.open("w");

  //alert('"Start "Thunderbird" /B /MIN "' + pgm + '" '  + option);

  batch_file.write('Start "Thunderbird" /B /MIN "' + pgm + '" '  + option );

  batch_file.close;

  batch_file.execute();

*/

};

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 03, 2015 Dec 03, 2015

Copy link to clipboard

Copied

Thanks JJMack, this looks interesting. I'll have a play around with it and see if I can get it to work for me!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines