Selektierte Datei(en) per Email senden (Outlook)

German support forum

Moderators: white, Hacker, Stefan2

dehein2
Junior Member
Junior Member
Posts: 25
Joined: 2013-04-15, 13:38 UTC

Selektierte Datei(en) per Email senden (Outlook)

Post by *dehein2 »

Hallo zusammen,

es gibt ja das Kontextmenü Senden am -> E-Mail mit dem man eine (oder mehrere Dateien) an Outlook/Lotus Notes senden kann und eine neue E-Mail geöffnet wird.

Ich würde das ganze gerne mit einem einfach shortcut lösen. Also Datei/Dateien markieren STRG+irgendwas drücken und das Mail-Programm öffnet sich.
Lässt sich das ganze einfach mit TC realisieren??

Vielen Dank
Dennis
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Nein, weil das über OLE2 an Outlook gesendet wird. Es ginge höchstens über ein Scriptingtool wie Autohotkey, das dann die entsprechenden Tasten simuliert.
Author of Total Commander
https://www.ghisler.com
dehein2
Junior Member
Junior Member
Posts: 25
Joined: 2013-04-15, 13:38 UTC

Post by *dehein2 »

ok, schade.

Danke für die Info.

VG
Dennis
peter_jupiter
Junior Member
Junior Member
Posts: 97
Joined: 2007-09-15, 19:44 UTC
Location: Austria

Post by *peter_jupiter »

Liebe Forumfreunde,
ich bin seit ganz vielen Jahren Fan von TC, wüßte gar nicht was ich ohne ihn machen sollte. Nur die Sache mit Datei markieren und dann per email (outlook) senden, das brauche ich immer mal wieder. Gibt es den keine Möglichkeit, oder noch keine Möglichkeit so eine Funktion zu realisieren. Habe die Posts gelesen, aber es ist ja schon wieder einige Zeit vergangen, und die Entwicklung geht ja immer weiter.
Danke und LG
Peter
User avatar
tuska
Power Member
Power Member
Posts: 3741
Joined: 2007-05-21, 12:17 UTC

Post by *tuska »

Hallo, vielleicht suchst Du das oder sowas ähnliches wie hier beschrieben:
http://ghisler.ch/board/viewtopic.php?t=42397

Letztendlich habe ich mir das damals so eingerichtet:
Kommando: outlook
Parameter: /a %P%N
Icondatei: C:\WINDOWS\System32\shell32.dll => das Brief-Symbol!
Tooltip: Strg + E | Datei unter Cursor mit Outlook versenden | Button "Start" > Eingabe: "outlook" /a D:\Daten\Test.pdf
Shortcut: Strg + E => em_Datei_an_Email

Gruß
Karl
peter_jupiter
Junior Member
Junior Member
Posts: 97
Joined: 2007-09-15, 19:44 UTC
Location: Austria

Post by *peter_jupiter »

Hallo Karl,
danke für die prompte Antwort.
Bis zur Zeile Icondatei .. habe ich alles eingegeben, ich verstehe noch nicht die Funktion Tooltip: .....
Was muss bei Tooltip drin stehen ?
Welcher ist der Button "Start" ?
und wie funktioniert das mit dem Shortcut.
habe alles bis Icondatei eingegebn. Im Moment öffnet sich ein email Fenster wo die erste markiert Datei als Anhang mitgegeben wird, ist ja schon mal nicht schlecht, geht das auch für mehrere markierte Dateien ?
Danke nochmals für Deine Hilfe
LG
Peter
User avatar
tuska
Power Member
Power Member
Posts: 3741
Joined: 2007-05-21, 12:17 UTC

Post by *tuska »

Hallo Peter,

- Tooltip: Klicke auf einen freien Platz neben Deiner Symbolleiste und dann auf "Ändern...", danach erscheint ein Fenster. Ganz unten kannst Du im Feld "Tooltip" eine selbst gewählte Beschreibung zu dem/einem angelegten Button eingeben - dann auf "OK" klicken. Wenn Du danach mit dem Cursor etwas länger auf den Button zeigst, dann erscheint ein kleines Popup-Fenster in dem Deine selbst gewählte Beschreibung zum Button angezeigt wird - so etwas wie ein selbst erstellter kleiner Hilfetext.

- Button "Start": Hiemit ist gemeint, daß man alternativ auch ein Email mit einer Datei über den Windows Start-Button versenden kann. Z.B. unter Windows 10 den Start-Button links unten drücken und einfach drauflosschreiben: "outlook" /a D:\Daten\blabla.txt <ENTER> ... hat denselben Effekt wie eine Versendung einer Datei mit Strg+E aus dem TC.
Damit ich diese Variante nicht vergesse, habe ich mir das als Hilfetext in den Tooltip hineingeschrieben.

- Wie funktioniert das mit dem Shortcut?
1. Rechtsklick auf einen freien Platz neben der Symbolleiste
2. Button "Anfügen" drücken
3. Klick auf das Lupen-Symbol
4. Links unter "Kategorie" nach unten scrollen und Klick auf "usercmd.ini"
5. Klick auf Button "Neu..."
6. Neuer Name für Befehl eingeben, zB em_Datei_an_Email, dann OK drücken
7. Kommando, Parameter, Icondatei, Tooltip erfassen
8. OK, OK, OK drücken
9. Menü "Konfigurieren" - Einstellungen - Diverses auswählen
10. Tastenkombinationen umdefinieren: zum Beispiel
a) anhaken von "Strg +",
b) dann rechts außen das Dropdown-Feld anklicken und zB den Buchstaben "E" auswählen
11. In der Zeile von "Befehl" auf die Lupe klicken
12. In der Kategorie wieder usercmd.ini auswählen
13. Den Befehl "em_Datei_an_Email" anklicken, dann OK-Button drücken
14. ACHTUNG - Wichtig: Jetzt den grünen Pfeil rechts von der Lupe anklicken
15. OK anklicken
FERTIG

Ab jetzt sollte mit dem zeigen auf eine Datei im TC (Markierung nicht erforderlich) und drücken von Strg + E eine neue Outlook-Nachricht erscheinen, bei dem automatisch die Datei als Anhang vorhanden ist.

Geht das auch für mehrere markierte Dateien?
Leider ist mir hier keine Lösung bekannt.

Gruß
Karl
peter_jupiter
Junior Member
Junior Member
Posts: 97
Joined: 2007-09-15, 19:44 UTC
Location: Austria

Post by *peter_jupiter »

Hallo Karl,
danke für diese tolle Lehrstunde, das ist urlieb von Dir.
Vielen Vielen Dank und alles Gute
Es steckt sicher noch viel mehr Funktion in TC drin, begeistert mich immer wieder.
Wenn noch jemand eine Idee hat wie das mit mehreren Dateien geht dann bin ich sehr dankbar.
lg
Peter
User avatar
Stefan2
Power Member
Power Member
Posts: 4133
Joined: 2007-09-13, 22:20 UTC
Location: Europa

VBScript: For Each Selected File - Add To Outlook.vbs

Post by *Stefan2 »

Danke für die Anleitung, Karl. Ich werde sie in meine FAQs aufnehmen.

- - -

>>> Geht das auch für mehrere markierte Dateien?

Ich hab' mal etwas gegooggelt...


-- The /a switch can be used to send 1 file as an attachment. No for multiple files.
Ken Slovak [MVP - Outlook]


https://support.office.com/en-us/article/Command-line-switches-for-Outlook-2010-ce2b9143-ceca-48ac-bffc-c3059a4c5919
>> Outlook
/a ---- Creates an item with the specified file as an attachment.
Example: "c:\program files\microsoft office\office15\outlook.exe" /a "c:\my documents\labels.doc"

TC can aid you by execute DOS commands and providing %Parameters to pass selected file names.
"c:\program files\microsoft office\office15\outlook.exe" /a "c:\my documents\labels.doc"
"c:\program files\microsoft office\office15\outlook.exe" /a %P%N
( right click an button in TC buttonbar, >> Change... >> [Help] )



-- To work around this use a commandline tool that can compress the files to a
single zip-file. Then you can easily use the commandline switch.
Robert Sparnaaij [MVP-Outlook] www.howto-outlook.com

-- Depending on what you are trying to achieve, you can use the
Outlook Object Model to attach multiple files as well.
Robert Sparnaaij [MVP-Outlook]



Dazu hat ein Anwender ein VBScript gepostet:

Code: Select all

http://www.pcreview.co.uk/threads/command-line-switch-to-attach-multiple-files.3830512/

    Jack B. Pollack Guest

    If anyone is interested I wrote this VB script to replace the built in "Send
    To Mail Recipient" item. It doesn't insert all the BS text the default one
    does.

    Save the script as "Mail Recipient.vbs" in you MS office folder.
    Delete the "Mail recipient" item in your "%homepath%/sendto" folder
    Create a shortcut to the new Mail Recipient script in the sendto folder
    Change the icon to the new shortcut to "%SystemRoot%\system32\sendmail.dll"


    On Error Resume Next
    Set App = GetObject(, "Outlook.Application")
    If Err <> 0 Then Set App = CreateObject("Outlook.Application")
    Set AppItem = App.CreateItem(0)

    If WScript.Arguments.Count > 0 then
	    For FileName = 0 to (WScript.Arguments.Count - 1)
	    		AppItem.Attachments.Add WScript.Arguments(FileName)
	    Next
	    AppItem.Display
    End If

    Set App = Nothing
    Set AppItem = Nothing

Dieses habe ich in ein VBScript zur Verwendung mit TC eingebaut.

Bei Interesse bitte mal testen.... (EDIT: die VBS funktioniert bei mir: Win7/32-bit und Outlook 2003)

21.10.2015, VBS "Einzeldateien" v0.01, Füge jede ausgewählte Datei zu Outlook hinzu, jede einzeln:

Code: Select all

'// // // // // // // // // // // // // // // // // // // // // // // // // // 
' Found at http://ghisler.ch/board/viewtopic.php?p=301286#301286
'// ForEachSelFile-AddToOutlook.vbs
'// Example Attachment: file1, file2, file3, ...
'// Stefan, 21.10.2015, v0.01
'// Save as "ForEachSelFile-AddToOutlook.vbs" to TC folder.
'// Drag & drop to TC Buttonbar. Right click and adjust the settings:
'// CMD = "d:\rive\path\to\this.vbs"
'// PARAM = "%L"
'// Path=
'// Icon=C:\Windows\System32\WScript.exe
'// Tooltip: Write an description here...
'// (Press F1-key for more help)
'// // // // // // // // // // // // // // // // // // // // // // // // // // 
'// T H E   C O D E
On Error Resume Next
Set FSO = CreateObject("Scripting.FileSystemObject")
Set WSO  = Wscript.CreateObject("WScript.Shell")
'// // //
sTCtempList = Wscript.arguments.Item(0) ' The TC temp file due the "%L" param.
If  FSO.FileExists(sTCtempList) Then

	Const FORREADING = 1
	'//Little debugging:
	'WSO.run "notepad " & sTCtempList

	'// Work with Outlook:
	Set App = GetObject(, "Outlook.Application")
	If Err <> 0 Then Set App = CreateObject("Outlook.Application")
	Set AppItem = App.CreateItem(0)

	'//Read TCs' temp file list, and proceed line by line:
	Set oTextStream = FSO.OpenTextFile(sTCtempList,FORREADING)
	Do Until oTextStream.AtEndOfStream
		vFullName = oTextStream.ReadLine
		
		'//Little debug (Prefix line with ' -sign to disable):
 		ret = MsgBox("File: "&vFullName&vbCRLF&vbCRLF&"Continue?", vbOKCancel,"TC VBS")
		If (ret=vbCancel) Then WScript.Quit
		
		'//Add current file name to Outlook:
		AppItem.Attachments.Add  vFullName
		
	Loop
	oTextStream.Close
	'//Open Outlook:
	AppItem.Display

Else
	WScript.Echo "Input file " & sTCtempList & " not found."
End If
'// // //
MsgBox "Finished.",,"TC VBS"
'//housekeeping:
Set App = Nothing
Set AppItem = Nothing
Set FSO = Nothing
Set WS = Nothing
'//EOF
'// // // // // // // // // // // // // // // // // // // // // // // // // // 


27.10.2015, VBS "Einzeldateien" v0.02, Füge jede ausgewählte Datei zu Outlook hinzu, jede einzeln (improved version):

Code: Select all

'// // // // // // // // // // // // // // // // // // // // // // // // // //
' Found at http://ghisler.ch/board/viewtopic.php?p=301286#301286
'// ForEachSelectedFile_AddToOutlook_02.vbs
'// Example Attachment: file1, file2, file3, ...
'// Stefan, 27.10.2015, v0.02 (+cleaned-up +better error handling +plus found more nifty things to add)
'// Save this file to TC folder.
'// Drag & drop to TC Buttonbar. Right click and adjust the settings:
'// CMD = "d:\rive\path\to\this.vbs" (already filled due to drag&drop)
'// PARAM = "%L"
'// Path=
'// Icon=C:\Windows\System32\WScript.exe (or  C:\WINDOWS\System32\imageres.dll (zB das Briefsymbol) )
'// Tooltip: Launch Outlook and add selected files as attachment
'// (Press F1-key for more help)
'// // // // // // // // // // // // // // // // // // // // // // // // // //
'// T H E   C O D E
'// NOTE:  ' is the comment symbol of VBS. This lines are disabled.
'// NOTE:  '// is my comment symbol for description lines.
'On Error Resume Next
Set FSO = CreateObject("Scripting.FileSystemObject")
Set WSO  = Wscript.CreateObject("WScript.Shell")
'// // //
sTCtempList = Wscript.arguments.Item(0) ' The TC temp file due to TCs "%L" parameter.
If  FSO.FileExists(sTCtempList) Then
   '//Little debugging:
			'WSO.run "notepad " & sTCtempList

   '// Work with Outlook Object:
		   Set AppObj = GetObject(, "Outlook.Application")
		  'Set AppObj = CreateObject("Outlook.Application")
		   If Err.Number <> 0 Then 
				Msgbox "Can not connect to Outlook Object. Is Outlook installed? " _
				     & vbCRLF&vbCRLF&"ERROR: "&vbCRLF&Err.Description,,"TC VBS - Error"
				WScript.Quit
		   End IF
		   Set AppItem = AppObj.CreateItem(0)

   '//Read TCs' temp file list, and proceed line by line:
		   Const FORREADING = 1
		   Set oTextStream = FSO.OpenTextFile(sTCtempList,FORREADING)
		   Do Until oTextStream.AtEndOfStream
		   
				  vFullName = oTextStream.ReadLine
				  
				  '//Little debug (Prefix next line with ' -sign to disable):
				  'Debug = MsgBox("File: "&vFullName&vbCRLF&vbCRLF&"Continue, or cancel script?", vbOKCancel,"TC VBS")
				  'If (Debug=vbCancel) Then WScript.Quit
				  
				  '//Add current file name to Outlook:
				  AppItem.Attachments.Add  vFullName
			  
		   Loop
		   oTextStream.Close
		   
   '//Configure the eMail (Prefix next lineS with ' -sign to disable):
		Signature = "X:\temp\Signature.html"
		Signature = "c:\Users\yourname\AppData\Roaming\Microsoft\Signatures\yourname.htm"
		Signature = FSO.GetFile(Signature).OpenAsTextStream(1, -2).ReadAll
		myBody = "Hello,<br /><br />Please find the <b>wanted</b> files from " 
		myBody = myBody & timestamp & " as attachment.<br /><br /><br />" 
		
       With AppItem
			'.From 		= "Total Commander Forum"
			.Subject    = "Here are the wanted files... "
			.To         = "Stefan@hulahulaisland.com"
			.Recipients.Add("abcdef8642@gmail.com")		' 2nd recipient
			.Recipients.Add("Stefan@Home.com")			' 3th recipient
			.CC			= "Fellow@Work.com"
			.BCC		= "Admin@Sofa.com"
			'.Body       = "Please find the wanted files as attachment."
			.HTMLBody    =  myBody & Signature
			'.Importance = Outlook.OlImportance.olImportanceHigh	'do this work?
			'.Attachments.Add ' another file
			'.Send()
		End With
	'//Open/Display Outlook:
   		AppItem.Display
	'//Auto logon and send: http://www.borncity.com/web/WSHBazaar1/WSHoutl.htm
Else

	sUsage = "USAGE:"& vbCRLF
	sUsage = sUsage  & "Save this file as ForEachSelectedFile_AddToOutlook_01.vbs to TC folder." & vbCRLF
	sUsage = sUsage  & "Drag & drop to TC Buttonbar. Right click and adjust the settings:" & vbCRLF & vbCRLF
	sUsage = sUsage  & "CMD="&chr(34)&"d:\rive\path\to\this.vbs"&chr(34)&" (already filled due to drag&drop)" & vbCRLF
	sUsage = sUsage  & "Param="&chr(34)&"%L"&chr(34) & vbCRLF
	sUsage = sUsage  & "Path=" & vbCRLF
	sUsage = sUsage  & "Icon="&chr(34)&"C:\WINDOWS\System32\imageres.dll"&chr(34)&" (choose the Letter symbol)" & vbCRLF
	sUsage = sUsage  & "Tooltip: Launch Outlook and add selected files as attachment" & vbCRLF & vbCRLF
	sUsage = sUsage  & "USE THE QUOTES! as shown above for CMD and PARAM and ICON" & vbCRLF
	WScript.Echo "Input file sTCtempList not found."&vbCRLF&"Please call script from within TC and with parameter "&chr(34)&"%L"&chr(34)
	MsgBox sUsage,,"TC VBS - Instructions"
	WScript.Quit
	
End If
'// // //
'//All done (Prefix next line with ' -sign to disable):
'MsgBox "Finished.",,"TC VBS - Good bye!"
'//housekeeping:
Set AppObj  = Nothing
Set AppItem = Nothing
Set FSO     = Nothing
Set WSO     = Nothing
'// // //
Function timestamp()
    N = Now
    W = WeekdayName( Weekday(N), false)
    D = Year(N) & "." & Right("00" & Month(N), 2) & "." & Right("00" & Day(N), 2)
    T = Right("00" & Hour(N), 2) & ":" & Right("00" & Minute(N), 2) & ":" & Right("00" & Second(N), 2)
	timestamp = D & ", " & W & " " &T
END Function 'timestamp	
'//EOF
'// // // // // // // // // // // // // // // // // // // // // // // // // // 
' '''  "X:\temp\Signature.html" contains:
' '''  	<br />
' '''  	<br />
' '''  	sincerely yours<br />
' '''  	<br />
' '''  	<b>Stefan</b><br />
' '''  	Overworked and underpaid.<br />
' '''  	-----------------------<br />
' '''  	Twitter:	<br />
' '''  	Facebook:	<br />
' '''  	Xing:		<br />
' '''  Or use orign from c:\Users\yourname\AppData\Roaming\Microsoft\Signatures\yourname.htm
'// // // // // // // // // // // // // // // // // // // // // // // // // // 

HTH?


- - -

EDIT:

Stecke die selektierten Dateien in ein ZIP-Archiv und sende dies an Outlook:

2015-10-21, BATCH "Archiv" v0.01, Zippe alle ausgewählten Datein und füge das Zip Outlook hinzu:

Code: Select all

@ECHO OFF 
REM ' Found at http://ghisler.ch/board/viewtopic.php?p=301286#301286
REM Batch script "ForSelectedFiles_Do_AddToOutlook.cmd" 
REM Example Attachment: Archive.zip (with file1, file2, file3, ...)
REM by Stefan, 2015-10-21, v0.01
REM
REM Use from a Total Commander Button:
REM Command:   path\to\this\batch.cmd
REM Parameter: "%L"  "%Parchive.zip"   (see TC help for more)
REM
REM Usage: select a few files and execute the button.
REM
REM
REM THE CODE
SET listfiletxt=%~1
if [%listfiletxt%]==[] GoTo _ERROR

ECHO.
ECHO Zipping files to archive and adding to Outlook:
ECHO.
ECHO ---------------------------------
ECHO Set 7z @listfiletxt to %listfiletxt%
ECHO.
SET newARCH=%~2
ECHO Set new archive name to %newARCH%
ECHO ---------------------------------
ECHO.
ECHO.
ECHO * * * Calling 7Zip:
%Commander_Path%\TOOLs\Packer\7za.exe a %newARCH% @%listfiletxt%

ECHO.
ECHO * * * Calling Outlook
START "" outlook /a %newARCH%

ECHO.
REM ECHO * * * Deleting archive:
REM DEL %newARCH%

ECHO.
ECHO * * * All Done!
PAUSE
GoTo :EOF

:_ERROR
ECHO.
ECHO ! listfiletxt not found !
PAUSE
REM EOF
####################################


- - -

EDIT:

Stecke die selektierten Dateien in ein ZIP-Archiv und sende dies an Outlook:

2015-10-24, BATCH "Archiv" v0.02, Zippe alle ausgewählten Datein und füge das Zip Outlook hinzu.
Neu: mehr Anführungszeichen und TCs "%UL" Parameter für deutsche Umlaute.

Code: Select all

@ECHO OFF
REM Found at http://ghisler.ch/board/viewtopic.php?p=301286#301286
REM Batch script "ForSelectedFiles_Do_AddToOutlook.cmd" 
REM by Stefan, 2015-10-24, 
REM v0.02 (now with more quotes, and TCs %UL parameter for german umlauts)
REM
REM Use from a Total Commander Button:
REM Command:     "D:\rive\path\to\this\batch.cmd"
REM Parameter:   "%UL" "%Parchive.zip"
REM (Both cmd and para including the quotes. See TC help for more params)
REM Startpfad:   
REM Tooltip:     ForSelectedFiles_Do_AddToOutlook.CMD
REM Icondatei:   C:\WINDOWS\System32\imageres.dll (zB das Briefsymbol)

REM
REM Usage: select a few files and execute the button.
REM
REM
REM THE CODE
SET listfiletxt=%~1
IF ,%listfiletxt%,==,, GoTo _ERROR

REM NOTEPAD "%listfiletxt%"
ECHO.
ECHO Zipping files to archive and adding to Outlook:
ECHO.
ECHO ---------------------------------
ECHO Set 7z @listfiletxt to "%listfiletxt%"
ECHO.
SET newARCH=%~2
ECHO Set new archive name to "%newARCH%"
ECHO ---------------------------------
ECHO.
ECHO.
ECHO * * * Calling 7Zip:
REM http://www.7-zip.de/download.html  --- Standalone-Konsole
REM http://www.7-zip.org/download.html --- standalone console version
echo "%Commander_Path%\TOOLs\Packer\7za.exe "  a "%newARCH%" "@%listfiletxt%"
     "%Commander_Path%\TOOLs\Packer\7za.exe "  a "%newARCH%" "@%listfiletxt%"

ECHO.
ECHO * * * Calling Outlook
START "" outlook /a "%newARCH%"

ECHO.
REM ECHO * * * Deleting archive:
REM DEL /P 	  "%newARCH%"

ECHO.
ECHO * * * All Done!
PAUSE
GoTo :EOF

:_ERROR
ECHO.
ECHO ! listfiletxt not found !
ECHO "%listfiletxt%"
PAUSE
GoTo :EOF
REM EOF - Batch finished here. Information following:


###############################################################################
TC Button Code (Copy and paste to TCs Buttonbar)

TOTALCMD#BAR#DATA
"c:\temp\Test.cmd"
"%UL" "%Parchive.zip"
C:\Windows\System32\imageres.dll,15
Test


-1

###############################################################################
EXAMPLE OUTPUT:

Zipping files to archive and adding to Outlook:

---------------------------------
Set 7z @listfiletxt to "C:\Users\User\AppData\Local\Temp\CMDE8FE.tmp"

Set new archive name to "d:\d\MP3\archive.zip"
---------------------------------


* * * Calling 7Zip:
"X:\ToCo8\TOOLs\Packer\7za.exe "  a "X:\d\MP3\archive.zip" "@C:\Users\User\AppData\Local\Temp\CMDE8FE.tmp"

7-Zip (A) 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18
Scanning

Creating archive d:\d\MP3\archive.zip

Compressing  Apres - Ski Party 2014 Part 1.mp3
Compressing  Apres - Ski Party 2014 Part 1.txt
Compressing  Apres - Ski Party 2014 Part 2.mp3
Compressing  Apres - Ski Party 2014 Part 2.txt
Compressing  Peter Maffay - Über sieben Brücken mußt du gehn.mp3

Everything is Ok

* * * Calling Outlook
---- Outlook startet und hat Archive.zip als Attachment ------

* * * All Done!
Drücken Sie eine beliebige Taste . . .
###############################################################################


2015-10-25, BATCH "Archiv" v0.03, Zippe alle ausgewählten Datein und füge das Zip Outlook hinzu.
Neu: Lösche altes Archiv

Code: Select all

@ECHO OFF
REM Found at http://ghisler.ch/board/viewtopic.php?p=301286#301286
REM Batch script "ForSelectedFiles_Do_AddToOutlook.cmd"
REM Example Attachment: Archive.zip (with file1, file2, file3, ...)
REM by Stefan, 2015-10-25, 
REM v0.02 (now with more quotes, and TCs %UL parameter for german umlauts)
REM v0.03 delete old archive, if existent
REM
REM Use from a Total Commander Button:
REM Command:     "D:\rive\path\to\this\batch.cmd"
REM Parameter:   "%UL" 
REM (Both cmd and para including the quotes. See TC help for more params)
REM Startpfad:   
REM Tooltip:     ForSelectedFiles_Do_AddToOutlook.CMD
REM Icondatei:   C:\WINDOWS\System32\imageres.dll (zB das Briefsymbol)

REM
REM Usage: select a few files and execute the button.
REM
REM
REM THE CODE
SET listfiletxt=%~1
IF ,%listfiletxt%,==,, GoTo _ERROR

REM NOTEPAD "%listfiletxt%"
ECHO.
ECHO Zipping files to archive and adding to Outlook:
ECHO.
ECHO ---------------------------------
ECHO Set 7z @listfiletxt to "%listfiletxt%"
ECHO.
SET newARCH=%TEMP%\archive.zip
ECHO Set new archive name to "%newARCH%"
ECHO ---------------------------------
ECHO.
if exist "%newARCH%" DEL "%newARCH%"

ECHO.
ECHO * * * Calling 7Zip:
REM http://www.7-zip.de/download.html  --- Standalone-Konsole
REM http://www.7-zip.org/download.html --- standalone console version
echo "%Commander_Path%\TOOLs\Packer\7za.exe "  a "%newARCH%" "@%listfiletxt%"
     "%Commander_Path%\TOOLs\Packer\7za.exe "  a "%newARCH%" "@%listfiletxt%"

ECHO.
ECHO * * * Calling Outlook
START "" outlook /a "%newARCH%"

ECHO.
ECHO * * * All Done!
PAUSE
GoTo :EOF

:_ERROR
ECHO.
ECHO ! listfiletxt not found !
ECHO "%listfiletxt%"
PAUSE
GoTo :EOF


2015-10-25, VBS "Archiv" v0.01, Zippe alle ausgewählten Datein und füge das Zip Outlook hinzu.
Die BATCH "Archiv" v0.03, diesmal als VBS:

Code: Select all

'// // // // // // // // // // // // // // // // // // // // // // // // // //
' Found at http://ghisler.ch/board/viewtopic.php?p=301286#301286
'// ForEachSelFile-ZIP_and_AddToOutlook.vbs
'// Example Attachment: Archive.zip ( with file1, file2, file3, ...)
'// Stefan, 25.10.2015, v0.01
'// Save as "ForEachSelFile-ZIP_and_AddToOutlook.vbs" to TC folder.
'// Drag & drop to TC Buttonbar. Right click and adjust the settings:
'// CMD = "d:\rive\path\to\this.vbs"
'// PARAM = "%L"
'// Path=
'// Icon=C:\Windows\System32\WScript.exe
'// Tooltip: Write an description here...
'// (Press F1-key for more help)
'// // // // // // // // // // // // // // // // // // // // // // // // // //
'// T H E   C O D E
On Error Resume Next

If Wscript.arguments.Count = 1 Then

      Set FSO = CreateObject("Scripting.FileSystemObject")
      Set WSO  = Wscript.CreateObject("WScript.Shell")

      vTCPath = WSO.ExpandEnvironmentStrings( "%Commander_Path%" )
      vUTemp = WSO.ExpandEnvironmentStrings( "%TEMP%" )
      vNameOfArchive = vUTemp & "\archive.zip"
      IF FSO.FileExists(vNameOfArchive) Then FSO.FileDelete(vNameOfArchive)

      sTCtempList = Wscript.arguments.Item(0) ' The TC temp file due the "%L" param.
      If  FSO.FileExists(sTCtempList) Then

          WSO.run chr(34) & vTCPath & "\TOOLs\Packer\7za.exe" & chr(34) & " a " _
                        & chr(34) & vNameOfArchive & chr(34) & " " & chr(34) & "@sTCtempList" & chr(34)

          WSO.run "outlook /a " & chr(34) & vNameOfArchive & chr(34)

      Else
         WScript.Echo "Input file sTCtempList not found."
      End If
      
ELSE
  Msgbox "Wrong or missing Parameter in TC Button! Script ends here!"
  WScript.Quit()
End If 'Wscript.arguments.Count 
MsgBox "Finished.",,"TC VBS"
Set FSO = Nothing
Set WSO = Nothing
'// // // // // // // // // // // // // // // // // // // // // // // // // // 
- - -

NOTE:
vTCPath & "\TOOLs\Packer\7za.exe"
is
"%Commander_Path%\TOOLs\Packer\7za.exe"
could be (depends on your environment)
"X:\TotalCommander\TOOLs\Packer\7za.exe"

- - -

Used archive tool:

http://www.7-zip.de/download.html --- Standalone-Konsole
http://www.7-zip.org/download.html --- standalone console version

- - -


Erklärung Kommentarzeichen   '   und   '//   und   REM:
Das Kommentarzeichen für VBS ist ein '
Oder eben auch das alte REM von DOS Batch.
Das '// ist nur etwas kosmetischer Schnick-Schnack.
Das // ist eigentlich das Kommentarzeichen von JavaScript. Und um das ' von VBS etwas hervorzuheben, verwende ich für Kommentare '//
Und zum auskommentieren von Programm-Code das Kommentarzeichen ' alleine.


- - -


Erklärung zu den Quotes:

Alle Pfad und Parameter werden in Anführungszeichen gesetzt. (Manchmal etwas kniffelig, wie und wo genau)

Eigentlich haben wir die Quotes bereits im TC-Button angegeben:
REM Command: "D:\rive\path\to\this\batch.cmd"
REM Parameter: "%UL" "%Parchive.zip"


Da es manchmal schwer ist, die Vorgehensweise des Quotings vom TC einzuschätzen,
haben wir eventuell übergebene Quotes erstmal wieder entfernt:
SET listfiletxt=%~1
SET newARCH=%~2

und dann wieder selbst hinzugefügt:
"%Commander_Path%\TOOLs\Packer\7za.exe " a "%newARCH%" "@%listfiletxt%"



 
Last edited by Stefan2 on 2015-10-27, 09:56 UTC, edited 5 times in total.
User avatar
tbeu
Power Member
Power Member
Posts: 1336
Joined: 2003-07-04, 07:52 UTC
Location: Germany
Contact:

Re: Datei per Email senden - Shortcut

Post by *tbeu »

dehein2 wrote:Lässt sich das ganze einfach mit TC realisieren??
blat.tbeu.de könnte helfen :wink:
TC plugins: Autodesk 3ds Max / Inventor / Revit Preview, FileInDir, ImageMetaData (JPG Comment/EXIF/IPTC/XMP), MATLAB MAT-file Viewer, Mover, SetFolderDate, Solid Edge Preview, Zip2Zero and more
User avatar
tuska
Power Member
Power Member
Posts: 3741
Joined: 2007-05-21, 12:17 UTC

VBScript

Post by *tuska »

Hallo Stefan,
danke für Deine Versuche der Problemlösung für mehrere Dateien!
Habe dein Script versucht - noch ohne Erfolg. Die Schritte habe ich mitgeschrieben - kannst Du bitte mal drüberschauen wo hier der Haken sein könnte?

1. Programmcode in einen Editor kopieren, wie zB Notepad.
2. Die Datei unter folgendem Namen speichern: ForSelectedFiles_Do_AddToOutlook.cmd
Beispielsweise habe ich mir die Datei unter diesem Pfad abgelegt:
D:\Daten\Programme\Total Commander\TCD_USB-Stick\TC32-64USB\Tools\Outlook\
3. Die Datei "ForSelectedFiles_Do_AddToOutlook.cmd" mit gedrückter linker Maustaste
an einen freien Platz am Ende der Symbolleiste ziehen - wenn man anschließend
mit der Maus auf dieses Symbol zeigt erscheint ein Tooltip mit dem Namen
des Programms (ForSelectedFiles_Do_AddToOutlook) ohne Anzeige der Extension (.cmd)
4. Rechtsklick auf einen freien Platz in der Symbolleiste, dann Button "Ändern"
Bei meiner portablen TC-Installation erscheint nun unter
Kommando: "%COMMANDER_PATH%\Tools\Outlook\ForSelectedFiles_Do_AddToOutlook.cmd"
Startpfad: %COMMANDER_PATH%\Tools\Outlook\
Tooltip: ForSelectedFiles_Do_AddToOutlook
Icondatei: C:\WINDOWS\System32\imageres.dll
Hier könnte zB als Symbol das Briefsymbol ausgewählt werden.
Parameter: "%L" "%Parchive.zip"
5. Button "OK" drücken
6. Die Datei: ForSelectedFiles_Do_AddToOutlook.cmd muß nochmals wegen dem Packprogramm
bearbeitet werden ... der Pfad zum Packprogramm 7-Zip muß noch eingestellt werden.
Ich habe mir das Plugin Total7zip für den TC installiert von dieser Seite:
http://totalcmd.net/plugring/total7zip.html
Im Programmcode habe ich folgendes geändert:
VON: %Commander_Path%\TOOLs\Packer\7za.exe a %newARCH% @%listfiletxt%
AUF: REM %Commander_Path%\TOOLs\Packer\7za.exe a %newARCH% @%listfiletxt%
AUF: %Commander_Path%\Plugins\wcx\Total7zip\7zG.exe a %newARCH% @%listfiletxt%
Datei > Beenden > Speichern...
FERTIG

7. Dateien markieren, dann Button drücken > jetzt sollte ein Outlook-Fenster
mit den angehängten Dateien erscheinen!?
1 Datei markiert
2 Dateien markiert - nicht zusammenhängend
4 Dateien markiert - zusammenhängend
Der Bildschirm flimmert kurz, d.h. im Hintergrund passiert was,
aber der Erfolg trifft noch nicht ein.

Danke nochmals!

Gruß
Karl
User avatar
Stefan2
Power Member
Power Member
Posts: 4133
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Post by *Stefan2 »

Hallo tuska, sehr gut beschrieben! Super gemacht! :thumpsup:


Sieht alles soweit gut aus.

Aber wenn der Bildschirm nur kurz flimmert,
stimmt etwas mit dem Buttonkommando oder der Batchdatei nicht.



Eigentlich solltest du zumindest (in etwa) das Folgende sehen:

ECHO Zipping files to archive and adding to Outlook:
ECHO.
ECHO ---------------------------------
ECHO Set 7z @listfiletxt to %listfiletxt%
ECHO.
SET newARCH=%~2
ECHO Set new archive name to %newARCH%
ECHO ---------------------------------



Bei mir hatte die Batch funktioniert.



Bei deiner Beschreibung fällt mir eine Besonderheit auf:
lass mal das Feld bei 'Startpfad' leer.


Und dann kann ich nicht sagen ob die GUI Version (7zG.exe)
auch mit den Kommandozeilenbefehlen der 7zA.exe klar kommt....


Ahh, eins noch: wird bei dir Outlook gestartet, wenn du 'outlook' im Ausführen-Dialog (Win+R !) eingibst?



Ich schau noch mal drüber,... aber übers WE steht mir kein Outlook zur Verfügung.



 
User avatar
tuska
Power Member
Power Member
Posts: 3741
Joined: 2007-05-21, 12:17 UTC

Post by *tuska »

Hallo Stefan2,
danke für Deine prompte Rückmeldung.

Habe das Feld bei 'Startpfad' nun leergelassen.
Beim nächsten ausführen des Buttons habe ich einen Bruchteil von einer Sekunde
vermutlich das DOS-Fenster gesehen aber keine erwartete Ausführung.

Outlook wird gestartet, wenn ich 'outlook' im Ausführen-Dialog (Win+R !) eingebe.

Um zu prüfen, ob das Problem das Plugin Total7zip mit der 7zG.exe betrifft,
habe ich nun das 7zip Plugin 0.7.6.5a von dieser Seite heruntergeladen,
da ich vermutet habe, daß die Datei 7zA hier beinhaltet sein könnte:
http://totalcmd.net/plugring/7zip_plugin.html
Da gab es allerdings einen Seiteneffekt: Norton 360 Premier (Internetsicherheit) hat
folgendes angemerkt: "7zip.wcx64 ist nicht sicher. Ausgeführte Aktion: entfernen".
Daraufhin habe ich die Downloaddatei gelöscht und die Installation des Plugins
abgebrochen. Dem gehe ich jetzt nicht weiter nach.

Somit habe ich mir einen Download von hier abgeholt
(vorher nochmals Windows-Taste + Pause-Taste gleichzeitig gedrückt,
damit die richtige Version heruntergeladen wird)
http://www.7-zip.de/download.html
Entschieden habe ich mich für: http://7-zip.org/a/7z920-x64.msi
(Hier hat Norton nach dem Download übrigens sofort angezeigt, dass die Datei sicher ist.)

Bei dem installierten Programm 7-Zip fand ich allerdings keine 7zA.exe
Es gibt hier nur diese Dateien:
7z.exe
7zFM.exe
7zG.exe

Eine kurze Google Recherche zu 7zA.exe ergab dies:
http://sourceforge.net/p/sevenzip/discussion/45797/thread/ab04ac1e
mit dem Link (Achtung: Wenn man ihn anklickt erfolgt sofort ohne Rückfrage der Download)
http://downloads.sourceforge.net/sevenzip/7za920.zip
readme.txt: 7za.exe is a standalone command line version of 7-Zip
D.h. die Installation von 7-Zip wäre eigentlich nicht erforderlich gewesen.
Ja, man sollte sich angewöhnen den Programmcode noch sorgfältiger zu lesen
und evtl. vorher schon zu recherchieren ;-)

Egal ob ich nun den den Pfad wie folgt angebe
a) D:\Daten\Programme\Total Commander\TCD_USB-Stick\TC32-64USB\Tools\7-zip-A\7za.exe a %newARCH% @%listfiletxt%
b) %Commander_Path%\TOOLs\7-zip-A\7za.exe a %newARCH% @%listfiletxt%
und Outlook vorher geschlossen oder geöffnet ist erscheint in jedem Fall
nach anklicken des Buttons nur ganz kurz im Hintergrund das DOS-Fenster
welches sofort wieder verschwindet.

Windows 10 Pro, 64-Bit-Betriebssystem, x64-basierter Prozessor.

Bitte daher nochmals um Prüfung. Danke!

@tbeu: Danke auch für Deine Verlinkung - ist mir nach kurzer Sichtung noch
zu steil - aber vielleicht komme ich noch darauf zurück.

Gruß
Karl
User avatar
tuska
Power Member
Power Member
Posts: 3741
Joined: 2007-05-21, 12:17 UTC

Post by *tuska »

Ergänzung: Microsoft Outlook 2013
Gruß,
Karl
User avatar
Stefan2
Power Member
Power Member
Posts: 4133
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Post by *Stefan2 »

Ich habe den Batch-Code auch nochmal runtergeladen,

in eine Textdatei "Test.cmd" gespeichert,

----------------------------------------------------

dies auf die Buttonbar gezogen

[face=timesnewroman]TOTALCMD#BAR#DATA
c:\temp\Test.cmd

C:\Windows\System32\imageres.dll,-68
Test
c:\temp\

-1[/face]


----------------------------------------------------

und dort angeklickt, Ergebnis:

! listfiletxt not found !
Drücken Sie eine beliebige Taste . . .


----------------------------------------------------

Dann habe ich als Parameter > "%L" "%Parchive.zip" < eingegeben.

( MIT den Anführungszeichen!!! )


[face=timesnewroman]TOTALCMD#BAR#DATA
c:\temp\Test.cmd
"%L" "%Parchive.zip"
C:\Windows\System32\imageres.dll,-68
Test
c:\temp\

-1[/face]


----------------------------------------------------



und dies mal angeklickt, Ergebnis:



Zipping files to archive and adding to Outlook:

---------------------------------
Set 7z @listfiletxt to C:\Users\User\AppData\Local\Temp\CMDD407.tmp

Set new archive name to c:\temp\archive.zip
---------------------------------


* * * Calling 7Zip:

7-Zip (A) 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
Scanning

Creating archive c:\temp\archive.zip

Compressing Test.cmd
< die Datei, auf der gerade der Cursor steht.

Everything is Ok

* * * Calling Outlook


* * * All Done!
Drücken Sie eine beliebige Taste . . .


----------------------------------------------------

Ergebnis:


c:\temp\archive.zip 688 24.10.2015 12:21 -a--



Outlook (Ich hab' hier doch Outlook, hier 2003) startet und hat archive.zip als Attachment hinzugefügt.


----------------------------------------------------


Momentan fällt mir nichts ein, was du falsch gemacht haben könntest ...


----------------------------------------------------

Mein 7Zip ist die Kommandozeilenversion von der offiziellen 7z-Seite.

X:\ToCo8\TOOLs\Packer\7za.exe 587.776 18.11.2010 21:27 -a--









# # # # Test mit mehreren ausgewählten Dateien:



Zipping files to archive and adding to Outlook:

---------------------------------
Set 7z @listfiletxt to C:\Users\User\AppData\Local\Temp\CMD805E.tmp

Set new archive name to X:\ToCo8\TOOLs\Packer\archive.zip
---------------------------------


* * * Calling 7Zip:

7-Zip (A) 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
Scanning

Creating archive X:\ToCo8\TOOLs\Packer\archive.zip

Compressing 7-zip.chm
Compressing 7-zip.chw
Compressing 7z 9.20 History.txt
Compressing 7z readme.txt
Compressing 7z.sfx
Compressing 7za.exe
Compressing 7za.exe readme.txt
Compressing 7zCon.sfx
Compressing ARJ.txt
Compressing Backup-RAR-Script.cmd.txt
Compressing CABARC.DOC.txt
Compressing CABARC.EXE
Compressing DD.EXE
Compressing rar sfx infos.txt
Compressing Rar.exe
Compressing RAR.ini
Compressing Rar.txt
Compressing rarreg.key
Compressing rar_3-80_Help.txt
Compressing rar_5-00_Help.txt
Compressing ReadMe.txt
Compressing UnRAR.exe
Compressing UnZip.exe
Compressing upx in TC.txt
Compressing upx.doc.txt
Compressing upx.exe
Compressing WinRar ReadMe.txt

Everything is Ok

* * * Calling Outlook


* * * All Done!
Drücken Sie eine beliebige Taste . . .





X:\ToCo8\TOOLs\Packer\archive.zip 1.410.103 24.10.2015 12:54 -a--



 
Post Reply