-1

I have created VBA code for sending mails with different attachments to different addresses, via Thunderbird. The code looks correct but while creating particular mail bodies it uses still the first values. And the strange fact is that in the debugging window all looks correct and the values are changing.

$

Option Explicit  
Sub SendMailThunder_Click()  
Dim strEmpfaenger1 As String  
Dim strBetr As String  
Dim strBody As String  
Dim strFile2 As Variant  
Dim strTh As String  
Dim strCommand As Variant  
Dim Nazev As String
Dim vysledek As Variant
Dim Seznam As Excel.Worksheet
Dim PS As Integer
Dim y As Long

Set Seznam = ThisWorkbook.Worksheets("Ridici")
' number of items in the column
PS = Seznam.Cells(Rows.Count, 11).End(xlUp).Row

With Seznam
    For y = 4 To PS
    '  Name of attachment
    Nazev = .Cells(y, 12).Value
    '  selected email
    strEmpfaenger1 = .Cells(y, 15).Value
    strBetr = .Range("O1")
    strBody = .Range("O2")

     strTh = "C:\Users\alois.konecny\AppData\Local\Mozilla Thunderbird\thunderbird.exe"
    '  path to attachment
        cesta = .Range("N1")
    '   attachment including path
    priloha = "\" & Nazev & ".xls"
    vysledek = cesta & priloha
    strFile2 = vysledek
    strCommand = strCommand & " -compose " & "to=" & Chr(34) & strEmpfaenger1 & Chr(34)
    strCommand = strCommand & ",subject=" & Chr(34) & strBetr &  Chr(34)
    strCommand = strCommand & ",body=" & Chr(34) & strBody & Chr(34)
    strCommand = strCommand & ",attachment=" & "file:///" & Replace(strFile2, "\", "/")
    Shell strTh & strCommand, vbNormalFocus
    Next y

End With
End Sub  

$

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
aloisk
  • 1
  • 1

1 Answers1

-1

The code is a bit hard to read, but have your tried this:

file://

instead of

file:///  
András Ottó
  • 7,605
  • 1
  • 28
  • 38
Bas Verlaat
  • 842
  • 6
  • 8