

' Copyright : The following is release as Attribution-ShareAlike 4.0 International ' Purpose : Send e-mail using Mozilla Thunderbird e-mail client using VBA ' Author : Daniel Pineault, CARDA Consultants Inc. , vbOKOnly + vbCritical, "An Error has Occurred!" Resume Error_Handler_Exit Switch(Erl = 0, "", Erl 0, vbCrLf & "Line No: " & Erl) _ "Error Description: " & Err.Description & _ "Error Source: TB_SendEmail" & vbCrLf & _ "Error Number: " & Err.Number & vbCrLf & _ MsgBox "The following error has occurred" & vbCrLf & vbCrLf & _ On Error Resume Next If Not oWSHShell Is Nothing Then Set oWSHShell = Nothing Exit Sub SCmd = sCmd & "" "" Set oWSHShell = CreateObject( "WScript.Shell") SCmd = sCmd & "format=1," '1=html, 2=plain text SCmd = sCmd & "from='" & vAccount & "'," End If SCmd = sCmd & "'," End If End If If IsMissing(vAccount) = False Then SCmd = sCmd & "attachment='" For Each att In vAttachments


SCmd = sCmd & "attachment='" & vAttachments & "'," Else SCmd = sCmd & "bcc='" & vBCC & "'," End If If IsMissing(vAttachments) = False Then If IsArray(vAttachments) = False Then SCmd = sCmd & "cc='" & vCC & "'," End If If IsMissing(vBCC) = False Then SCmd = sCmd & "body='" & vBody & "'," End If If IsMissing(vCC) = False Then SCmd = sCmd & "subject='" & vSubject & "'," End If If IsMissing(vBody) = False Then

SCmd = sCmd & "to='" & vTo & "'," End If If IsMissing(vSubject) = False Then SCmd = "thunderbird -compose " "" If IsMissing(vTo) = False Then '- Public Sub TB_SendEmail( Optional vTo As Variant, _ĭim oWSHShell As Object Dim sCmd As String Dim att As Variant On Error GoTo Error_Handler ' Website : ' Purpose : Send e-mail using Mozilla Thunderbird e-mail client using VBA ' Copyright : The following is release as Attribution-ShareAlike 4.0 International ' (CC BY-SA 4.0) - ' Req'd Refs: Late Binding -> None required ' ' Input Variables: ' ~~~~~~~~~~~~~~~~ ' vTo : To Recipient email address string (semi-colon separated list) ' vSubject : Text string to be used as the email subject line ' vBody : Text string to be used as the email body (actual message) ' vCC : CC Recipient email address string (semi-colon separated list) ' vBCC : BCC Recipient email address string (semi-colon separated list) ' vAttachments : Single file -> fully qualified path and filename string ' Multiple files -> Array of attachment (complete file paths with ' filename and extensions) ' vAccount : E-mail address of the account to use for sending the email, ' if no match is found it will use the default account ' ' Usage: ' ~~~~~~ ' Start a Blank E-amil ' Call TB_SendEmail() ' Simple E-mail ' Call "My Subject", "My body.") ' Multiple Recipients ' Call "My Subject", "My body.") ' CC ' Call "My Subject", "My body.", ' Single Attachment ' Call "My Subject", "My body.",, , "C:\Temp\Book1.pdf") ' Multiple Attachments ' Call "My Subject", "My body.",, , Array("C:\Temp\Book1.pdf", "C:\Temp\Desert.jpg")) ' Using a Specific Account to Send the E-mail From ' Call "My Subject", "My body.",, ,, ' ' Revision History: ' Rev Date(yyyy/mm/dd) Description ' ************************************************************************************** ' 1 Initial Release ' 2 Made all input variable optional for the greatest ' flexibility. '- ' Procedure : TB_SendEmail ' Author : Daniel Pineault, CARDA Consultants Inc.
