简体   繁体   English

从 Excel 通过 Thunderbird 发送邮件时重复 1 封邮件

[英]Repeated 1 mail while sending mail via Thunderbird from Excel

I have created VBA code for sending mails with different attachments to different addresses, via Thunderbird.我已经创建了 VBA 代码,用于通过 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  

$

The code is a bit hard to read, but have your tried this:代码有点难读,但你有没有试过这个:

file://

instead of代替

file:///  

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM