powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Visual Basic [игнор отключен] [закрыт для гостей] / vbs+помогите
6 сообщений из 6, страница 1 из 1
vbs+помогите
    #34201458
yodgik
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Помогите разобраться как запустить этот скрипт из cmd
Private Function SignedMessage (
ByVal sFrom As String,
ByVal sTo As String,
ByVal sSubject As String,
ByVal sBody As String,
ByVal sAttachmentName As String,
ByVal sAttachmentFile As String,
ByVal sCertificateSerialNumber As String As CDO.Message )
Const csAttachment As String = "attachment;filename=""<FileName>"""
Const csAttachmentFileName As String = "<FileName>"
Const csContentDisposition As String = "urn:schemas:mailheader:content-
disposition"
Dim abSignatureData() As Byte
Dim oSignature As CDO.IBodyPart
Dim oSignedData As CAPICOM.SignedData
Dim oStream As ADODB.Stream
Set SignedMessage = New CDO.Message
With SignedMessage
.ReplyTo = sFrom
.From = sFrom
.To = sTo
.Subject = sSubject
'Create main body (= text + attachment).
With .BodyPart
.ContentMediaType = "multipart/signed;protocol=""application/x-
pkcs7-signature"";micalg=SHA1"
With .AddBodyPart
.ContentMediaType = "multipart/mixed"
With .AddBodyPart
.ContentMediaType = "text/plain;charset=""iso-8859-1"""
Set oStream = .GetDecodedContentStream
With oStream
.WriteText sBody
.Flush
.Close
End With
Set oStream = Nothing
End With
With .AddBodyPart
.ContentMediaType = "application/pdf"
.ContentTransferEncoding = "base64"
With .Fields
.Item(csContentDisposition) = Replace(csAttachment,
csAttachmentFileName, sAttachmentName)
.Update
End With
Set oStream = .GetDecodedContentStream
With oStream
.LoadFromFile sAttachmentFile
.Flush
.Close
End With
Set oStream = Nothing
End With
End With
'Now add the signature.
'Don't get content to sign until the message's structure is
complete.
Set oSignature = .AddBodyPart
With oSignature
.ContentMediaType = "application/x-pkcs7-signature"
.ContentTransferEncoding = "base64"
With .Fields
.Item(csContentDisposition) = Replace(csAttachment,
csAttachmentFileName, "smime.p7s")
.Update
End With
'Now create the signature as a byte array.
'Doing this with a byte array variable otherwise
Stream.Write will report an error.
Set oSignedData = New CAPICOM.SignedData
With oSignedData
.Content = MessageContent
(SignedMessage.GetStream.ReadText)
abSignatureData = .Sign(CertificateSigner
(sCertificateSerialNumber), True, CAPICOM_ENCODE_BINARY)
End With
Set oSignedData = Nothing
Set oStream = .GetDecodedContentStream
With oStream
.Write abSignatureData
.Flush
.Close
End With
Set oStream = Nothing
End With
End With
End With
End Function
...
Рейтинг: 0 / 0
vbs+помогите
    #34201645
Фотография orunbek
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Форматирование хотя бы сделайте, а?
...
Рейтинг: 0 / 0
vbs+помогите
    #34201695
Настенька
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
вот сделала за него

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
Private Function SignedMessage (
ByVal sFrom As String, 
ByVal sTo As String,
ByVal sSubject As String, 
ByVal sBody As String, 
ByVal sAttachmentName As String, 
ByVal sAttachmentFile As String, 
ByVal sCertificateSerialNumber As String As CDO.Message )
Const csAttachment As String = "attachment;filename=""<FileName>"""
Const csAttachmentFileName As String = "<FileName>"
Const csContentDisposition As String = "urn:schemas:mailheader:content-
disposition"
Dim abSignatureData() As Byte
Dim oSignature As CDO.IBodyPart
Dim oSignedData As CAPICOM.SignedData
Dim oStream As ADODB.Stream
Set SignedMessage = New CDO.Message
With SignedMessage
.ReplyTo = sFrom
.From = sFrom
.To = sTo
.Subject = sSubject
'Create main body (= text + attachment).
With .BodyPart
.ContentMediaType = "multipart/signed;protocol=""application/x-
pkcs7-signature"";micalg=SHA1"
With .AddBodyPart
.ContentMediaType = "multipart/mixed"
With .AddBodyPart
.ContentMediaType = "text/plain;charset=""iso-8859-1"""
Set oStream = .GetDecodedContentStream
With oStream
.WriteText sBody
.Flush
.Close
End With
Set oStream = Nothing
End With
With .AddBodyPart
.ContentMediaType = "application/pdf"
.ContentTransferEncoding = "base64"
With .Fields
.Item(csContentDisposition) = Replace(csAttachment,
csAttachmentFileName, sAttachmentName)
.Update
End With
Set oStream = .GetDecodedContentStream
With oStream
.LoadFromFile sAttachmentFile
.Flush
.Close
End With
Set oStream = Nothing
End With
End With
'Now add the signature.
'Don't get content to sign until the message's structure is
complete.
Set oSignature = .AddBodyPart
With oSignature
.ContentMediaType = "application/x-pkcs7-signature"
.ContentTransferEncoding = "base64"
With .Fields
.Item(csContentDisposition) = Replace(csAttachment,
csAttachmentFileName, "smime.p7s")
.Update
End With
'Now create the signature as a byte array.
'Doing this with a byte array variable otherwise
Stream.Write will report an error.
Set oSignedData = New CAPICOM.SignedData
With oSignedData
.Content = MessageContent
(SignedMessage.GetStream.ReadText)
abSignatureData = .Sign(CertificateSigner
(sCertificateSerialNumber), True, CAPICOM_ENCODE_BINARY)
End With
Set oSignedData = Nothing
Set oStream = .GetDecodedContentStream
With oStream
.Write abSignatureData
.Flush
.Close
End With
Set oStream = Nothing
End With
End With
End With
End Function
...
Рейтинг: 0 / 0
vbs+помогите
    #34201868
yodgik
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Спасибо Настенька
...
Рейтинг: 0 / 0
vbs+помогите
    #34201891
yodgik
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
возможно ли заставить работать из cmd ??
...
Рейтинг: 0 / 0
vbs+помогите
    #34202092
Фотография buser
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Да - 1. убрать всё, что после AS; 2. использовать CreateObject; 3. входные параметры через коллекцию Args можно поиметь... Попробуйте, если не зар-ет выложите всё сюда.
...
Рейтинг: 0 / 0
6 сообщений из 6, страница 1 из 1
Форумы / Visual Basic [игнор отключен] [закрыт для гостей] / vbs+помогите
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]