Date of registration: Jan 1st 2009
Location: Hanover, Germany
Occupation: Software Engineer
Hobbies: Hilbert Curves
Date of registration: Jan 1st 2009
Location: Hanover, Germany
Occupation: Software Engineer
Hobbies: Hilbert Curves
|
|
Source code |
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 |
Public Sub JSendEmailFromOutlook( cTo As String, cSubject As String, cBody As String, Optional arrAttachments() As String, Optional lReadReceiptConfirmation As Boolean = False)
Dim oOutlook As com#jacob#activeX#ActiveXComponent
Dim oOL As com#jacob#com#Dispatch
Dim oNs As com#jacob#com#Dispatch
Dim oMail As com#jacob#com#Dispatch
Dim oAttachs As com#jacob#com#Dispatch
Dim mapi(0)As Object
Dim email(0) As Object
Dim nAttach As Integer
Dim attachment(0) As Object
mapi(0) = "MAPI"
email(0) = 0
Set oOutlook = New ActiveXComponent("Outlook.Application")
oOL = oOutlook.getObject()
oNs = com#jacob#com#Dispatch.call(oOL,"GetNamespace",mapi).toDispatch
oMail = com#jacob#com#Dispatch.call(oOutlook,"CreateItem",email).toDispatch
com#jacob#com#Dispatch.put(oMail, "To", cTo)
com#jacob#com#Dispatch.put(oMail, "Subject", cSubject)
com#jacob#com#Dispatch.put(oMail, "Body", cBody)
com#jacob#com#Dispatch.put(oMail, "ReadReceiptRequested", lReadReceiptConfirmation)
If Ubound(arrAttachments) > 0 Then
oAttachs = com#jacob#com#Dispatch.get(oMail, "Attachments").toDispatch()
For nAttach = 0 To Ubound(arrAttachments)
attachment(0) = arrAttachments(nAttach)
com#jacob#com#Dispatch.call(oAttachs, "Add", attachment)
Next nAttach
End If
com#jacob#com#Dispatch.call(oMail, "Send")
End Sub
|
This post has been edited 1 times, last edit by "joekaisaka" (Mar 17th 2011, 12:17pm)
|
|
Source code |
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 |
Public Sub JSendEmailFromOutlook( cTo As String, Optional cSubject As String = "", Optional cBody As String = "", Optional cCC As String = "", Optional cBCC As String = "", Optional arrAttachments() As String, Optional lReadReceiptConfirmation As Boolean = False, Optional nImportance As Integer = 0)
Dim oOutlook As com#jacob#activeX#ActiveXComponent
Dim oOL As com#jacob#com#Dispatch
Dim oNs As com#jacob#com#Dispatch
Dim oMail As com#jacob#com#Dispatch
Dim oAttachs As com#jacob#com#Dispatch
Dim mapi(0)As Object
Dim email(0) As Object
Dim nAttach As Integer
Dim attachment(0) As Object
mapi(0) = "MAPI"
email(0) = 0
Set oOutlook = New ActiveXComponent("Outlook.Application")
oOL = oOutlook.getObject()
oNs = com#jacob#com#Dispatch.call(oOL,"GetNamespace",mapi).toDispatch
oMail = com#jacob#com#Dispatch.call(oOutlook,"CreateItem",email).toDispatch
com#jacob#com#Dispatch.put(oMail, "To", cTo)
com#jacob#com#Dispatch.put(oMail, "Subject", cSubject)
If Len(Trim(cCC)) > 0 Then
com#jacob#com#Dispatch.put(oMail, "CC", cCC)
End If
If Len(Trim(cBCC)) > 0 Then
com#jacob#com#Dispatch.put(oMail, "BCC", cBCC)
End If
com#jacob#com#Dispatch.put(oMail, "Body", cBody)
com#jacob#com#Dispatch.put(oMail, "ReadReceiptRequested", lReadReceiptConfirmation)
com#jacob#com#Dispatch.put(oMail, "Importance", nImportance)
If Ubound(arrAttachments) > 0 Then
oAttachs = com#jacob#com#Dispatch.get(oMail, "Attachments").toDispatch()
For nAttach = 0 To Ubound(arrAttachments)
attachment(0) = arrAttachments(nAttach)
com#jacob#com#Dispatch.call(oAttachs, "Add", attachment)
Next nAttach
End If
com#jacob#com#Dispatch.call(oMail, "Send")
com#jacob#com#ComThread.Release
End Sub
|
Date of registration: Jan 1st 2009
Location: Hanover, Germany
Occupation: Software Engineer
Hobbies: Hilbert Curves
|
|
Jabaco Source |
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 |
Option Explicit Import com#jacob#activeX Import com#jacob#com Public Sub JSendEmailFromOutlook( cTo As String, cSubject As String, cBody As String, Optional arrAttachments() As String, Optional lReadReceiptConfirmation As Boolean = False) Dim oOutlook As ActiveXComponent Dim oOL As Dispatch Dim oNs As Dispatch Dim oMail As Dispatch Dim oAttachs As Dispatch Dim mapi(0)As Object Dim email(0) As Object Dim nAttach As Integer Dim attachment(0) As Object mapi(0) = "MAPI" email(0) = 0 Set oOutlook = New ActiveXComponent("Outlook.Application") oOL = oOutlook.getObject() oNs = Dispatch.call(oOL,"GetNamespace",mapi).toDispatch oMail = Dispatch.call(oOutlook,"CreateItem",email).toDispatch Dispatch.put(oMail, "To", cTo) Dispatch.put(oMail, "Subject", cSubject) Dispatch.put(oMail, "Body", cBody) Dispatch.put(oMail, "ReadReceiptRequested", lReadReceiptConfirmation) If Ubound(arrAttachments) > 0 Then oAttachs = Dispatch.get(oMail, "Attachments").toDispatch() For nAttach = 0 To Ubound(arrAttachments) attachment(0) = arrAttachments(nAttach) Dispatch.call(oAttachs, "Add", attachment) Next nAttach End If Dispatch.call(oMail, "Send") End Sub Public Sub Command1_Click() JSendEmailFromOutlook "xyz@myDomain.org", "Test", "a small" & vbCrLf & "Test" End Sub |