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
| Function SendMail(sSubject As String, sTo As String, sCC As String, _
sCCO As String, sAttach As String, sMessage As String) As Long
Dim i, cTo, ccc, cCCO, cAttach
Dim MAPI_Message As MAPIMessage
cTo = CountWord(sTo, ";")
ccc = CountWord(sCC, ";")
cCCO = CountWord(sCCO, ";")
cAttach = CountWord(sAttach, ";")
ReDim rTo(0 To cTo) As String
ReDim rCC(0 To ccc) As String
ReDim rCCO(0 To cCCO) As String
ReDim rAttach(0 To cAttach) As String
ParseWords rTo(), sTo, ";"
ParseWords rCC(), sCC, ";"
ParseWords rCCO(), sCCO, ";"
ParseWords rAttach(), sAttach, ";"
ReDim MAPI_Recip(0 To cTo + ccc + cCCO - 1) As MapiRecip
For i = 0 To cTo - 1
MAPI_Recip(i).Name = rTo(i)
MAPI_Recip(i).RecipClass = MAPI_TO
Next i
For i = 0 To ccc - 1
MAPI_Recip(cTo + i).Name = rCC(i)
MAPI_Recip(cTo + i).RecipClass = MAPI_CC
Next i
For i = 0 To cCCO - 1
MAPI_Recip(cTo + ccc + i).Name = rCCO(i)
MAPI_Recip(cTo + ccc + i).RecipClass = MAPI_CCO
Next i
ReDim MAPI_File(0 To cAttach) As MapiFile
MAPI_Message.FileCount = cAttach
For i = 0 To cAttach - 1
MAPI_File(i).Position = -1
MAPI_File(i).PathName = rAttach(i)
Next i
MAPI_Message.Subject = sSubject
MAPI_Message.NoteText = sMessage
MAPI_Message.RecipCount = cTo + ccc + cCCO
If GetDefaultMail = "Outlook Express" Then
SendMail = MAPISendMailOE(0&, 0&, MAPI_Message, MAPI_Recip(), MAPI_File(), MAPI_LOGON_UI, 0)
Else
SendMail = MAPISendMail(0&, 0&, MAPI_Message, MAPI_Recip(), MAPI_File(), MAPI_LOGON_UI, 0)
End If
End Function |
Partager