Total Commander Forum Index Total Commander
Форум поддержки пользователей Total Commander
Сайты: Все о Total Commander | Totalcmd.net | Ghisler.com | RU.TCKB
 
 RulesRules   SearchSearch   FAQFAQ   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Single Post  Topic: Отправка файла по почте с записью комментария в буфер 
Author Message
Batya



PostPosted: Thu Jun 03, 2010 10:23    Post subject: Reply with quote

AVos002 wrote:
причем это происходит так изящно

Надеюсь, что новый вариант будет не менее изящен:
Code:
'==============================================================
' Открытие нового сообщния MS Outlook с вложенными файлами
'
' Параметры:
' {файл для комментария} {файл-список файлов для вложения}
'
' Пример параметров при вызове из TC:
' %P%N %L
'==============================================================
Option Explicit
Dim FSO, MSO, MSG, File, List, F
Set FSO = CreateObject("Scripting.FileSystemObject")
File    = WScript.Arguments(0)
List    = WScript.Arguments(1)

Set MSO = CreateObject("Outlook.Application")
Set MSG = MSO.CreateItem(0)

MSG.Subject = FSO.GetFileName(File) & " [" & GetComment(File) & "]"
MSG.Body    = "Здравствуйте." & vbCrLf & vbCrLf & vbCrLf & _
              "До свиданья."  & vbCrLf & "Колобки"

For Each F In Split(FSO.OpenTextFile(List).ReadAll, vbNewLine)
  If F <> "" And FSO.FileExists(F) Then
    MSG.Attachments.Add F
  End If
Next

MSG.Display

Set MSG = Nothing
Set MSO = Nothing
Set FSO = Nothing
WScript.Quit

Function GetComment(pPath)
  Const CommFile = "descript.ion"
  Dim lPath, lName, lText, lComm
  lPath = FSO.GetParentFolderName(pPath)
  lName = FSO.GetFile(pPath).Name
  If Instr(lName, " ") > 0 Then lName = """" & lName & """"
  If lPath <> "" Then lPath = lPath & "\"
  If FSO.FileExists(lPath & CommFile) Then
    lText = FSO.OpenTextFile(lPath & CommFile).ReadAll
    lComm = Filter(Split(lText, vbNewLine), lName & " ", True, 1)
    If UBound(lComm) > - 1 Then
      GetComment = Replace(Mid(lComm(0), Len(lName) + 2), "В", "")
      GetComment = Trim(Replace(GetComment, "\n", " "))
    Else
      GetComment = ""
    End If
  Else
    GetComment = ""
  End If
End Function

Внимание - параметры поменялись.
И, как я понимаю, запись в буфер уже не нужна?
_________________
Нет, я не сплю. Я просто медленно моргаю.
View user's profile Send private message


Powered by phpBB © 2001, 2005 phpBB Group