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
|
'---------------------------------------------------------
' Send an Outlook e-mail with VBscript
'
' May-15th 2008 v1-0
'
' 1st argument is recipients (; is the e-mails separator)
' 2nd argument is THE attachement path (between quotes)
'---------------------------------------------------------
dim AttPath
dim Rmail
CdoPR_ATTACH_MIME_TAG = &H370E001E
if wscript.Arguments.length < 1 then
m = msgbox("Usage is:" & vbCrlf & "<e-mail @> <Attachement path>(Optional)",48,"WARNING")
Wscript.Quit
end if
Rmail = wscript.arguments(0)
if wscript.Arguments.length > 1 then
AttPath = wscript.arguments(1)
end if
Q=chr(34)
HTML_1 = "Salut, <br><br>Ca roule ? <br><br> regards <p><img border=" & Q & "0" & Q & " src=" & Q & "cid:Object_1" & Q & "></p>"
SendTO = Rmail
SendSUBJECT = "[TEST]"
Set ol = CreateObject("outlook.application")
Set myItem = ol.CreateItem(olMailItem)
If wscript.Arguments.length > 1 Then
Set myAttach = myItem.Attachments
Set myPictureAttached = myAttach.Add(AttPath)
End If
myItem.BCC = SendTO
myItem.Subject = SendSUBJECT
HTMLBodyToDisplay = HTML_1
myItem.HTMLBody = HTMLBodyToDisplay
myItem.OriginatorDeliveryReportRequested = False ' delivery confirmation
myItem.ReadReceiptRequested = False ' read confirmation
myItem.Close olSave
strEntryID = myItem.EntryID
Set myItem = Nothing
If wscript.Arguments.length > 1 Then
Set myPictureAttached = Nothing
End If
Set oSession = CreateObject("MAPI.Session")
oSession.Logon "", "", False, False
Set oMsg = oSession.GetMessage(strEntryID)
If wscript.Arguments.length > 1 Then
Set oAttachs = oMsg.Attachments
a = "Object_1"
Set oAttach = oAttachs.Item(1)
Set colFields = oAttach.Fields
Set oField = colFields.Add(CdoPR_ATTACH_MIME_TAG, "image/jpeg")
Set oField = colFields.Add(&H3712001E, a)
oMsg.Fields.Add "{0820060000000000C000000000000046}0x8514", 11, True
oMsg.Update
End If
Set l_Msg = ol.GetNamespace("MAPI").GetItemFromID(strEntryID)
l_Msg.HTMLBody = HTMLBodyToDisplay
l_Msg.Send
Set ol = Nothing
Set myItem = Nothing
oSession.Logoff
Set oSession = Nothing
Set objApp = Nothing
Set l_Msg = Nothing
Wscript.Quit |
Partager