【问题标题】:Repeated 1 mail while sending mail via Thunderbird from Excel从 Excel 通过 Thunderbird 发送邮件时重复 1 封邮件
【发布时间】:2015-12-19 15:10:36
【问题描述】:

我创建了 VBA 代码,用于通过 Thunderbird 将带有不同附件的邮件发送到不同的地址。代码看起来是正确的,但是在创建特定的邮件正文时,它仍然使用第一个值。而奇怪的事实是,在调试窗口中,一切看起来都是正确的,并且值正在发生变化。

$

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  

$

【问题讨论】:

  • 请正确格式化您的问题!
  • @pnuts - thank you for edit
  • 大家好,还有其他建议吗?

标签: excel vba email for-loop thunderbird


【解决方案1】:

代码有点难读,但你试过这个:

file://

而不是

file:///  

【讨论】:

  • @Bas Verlaat - thank you for suggestion. I tried this but it still doesn´t work
猜你喜欢
  • 2012-09-06
  • 2012-08-19
  • 2020-07-28
  • 1970-01-01
  • 1970-01-01
  • 2011-07-01
  • 2022-01-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多