VBA email attachments (1 Viewer)

pekajo

Registered User.
Local time
Today, 15:54
Joined
Jul 25, 2011
Messages
139
Hi,
Does anyone have a script to email an attachment that does not use Outlook as I use Thunderbird. Bot Perplexity and Gptchat cannot manage it.
Thanks
Peter
 
try this:
Code:
Sub SendEmailWithThunderbird()
    Dim thunderbirdPath As String
    Dim recipient As String
    Dim subject As String
    Dim body As String
    Dim attachmentPath As String
    Dim cmdLine As String
    
    ' Set Thunderbird executable path (adjust to your installation)
    thunderbirdPath = "C:\Program Files\Mozilla Thunderbird\thunderbird.exe"
    
    ' Email parameters
    recipient = "recipient@example.com"
    subject = "Email Subject"
    body = "Email body text"
    attachmentPath = "C:\Users\Administrator\Documents\Something.pdf"
    
    ' Build command line with mailto protocol
    cmdLine = """" & thunderbirdPath & """ -compose """ & _
              "to='" & recipient & "'," & _
              "subject='" & subject & "'," & _
              "body='" & body & "'," & _
              "attachment='" & attachmentPath & "'" & """"
    
    ' Execute Thunderbird with compose window
    Shell cmdLine, vbNormalFocus
    
    MsgBox "Thunderbird compose window opened with attachment", vbInformation
End Sub

Sub SendMultipleAttachments()
    Dim thunderbirdPath As String
    Dim cmdLine As String
    Dim attachments As String
    
    thunderbirdPath = "C:\Program Files\Mozilla Thunderbird\thunderbird.exe"
    
    ' Multiple attachments separated by comma
    attachments = "C:\File1.pdf,C:\File2.xlsx,C:\File3.docx"
    
    cmdLine = """" & thunderbirdPath & """ -compose """ & _
              "to='recipient@example.com'," & _
              "subject='Multiple Files'," & _
              "attachment='" & attachments & "'" & """"
    
    Shell cmdLine, vbNormalFocus
End Sub
 
Thank you so much it worked like a charm.
Peter
 

Users who are viewing this thread

Back
Top Bottom