簡體   English   中英

VBA Excel根據通話價值發送電子郵件

[英]VBA Excel Send Email based on call value

我對使用VBA有點陌生,並且能夠為大多數嘗試要做的事情找到正確的代碼。

我已經在Excel中創建了一個目錄,每個月我都必須向多個客戶端發送單獨的附件。

除了可以使用保存的Outlook簽名之外,我已經完成所有工作。

我已經找到了一些使用簽名的編碼,但是我不知道如何將其與已有的簽名合並。

到目前為止,我的代碼:

    Sub SendEmail() 
    Dim OutlookApp As Object 
    Dim MItem As Object 
    Dim cell As Range 
    Dim email_ As String 
    Dim cc_ As String 
    Dim subject_ As String 
    Dim body_ As String 
    Dim attach_ As String 

     'Create Outlook object
    Set OutlookApp = CreateObject("Outlook.Application") 

     'Loop through the rows
    For Each cell In Columns("a").Cells.SpecialCells(xlCellTypeConstants) 

        email_ = cell.Value 
        subject_ = cell.Offset(0, 1).Value 
        body_ = cell.Offset(0, 2).Value 
        cc_ = cell.Offset(0, 3).Value 
        attach_ = cell.Offset(0, 4).Value 



         'Create Mail Item and send it
        Set MItem = OutlookApp.CreateItem(0) 
        With MItem 
            .To = email_ 
            .CC = cc_ 
            .Subject = subject_ 
            .Body = body_ 
            .Attachments.Add attach_ 
             '.Display
        End With 
        MItem.Send 
    Next 
End Sub 

在Outlook中添加默認簽名

    'Create Mail Item and send it
    Set MItem = OutlookApp.CreateItem(0)
    With MItem              '<-----Added
        .Display            '<-----Added
    End With                '<-----Added
    signature = MItem.body  '<-----Added

    With MItem
        .To = email_
        .CC = cc_
        .Subject = subject_
        .body = body_ & vbNewLine & signature ' <-----Added (& vbNewLine & signature)
        .Attachments.Add attach_
         '.Display
    End With

如果將Outlook設置為在新郵件上生成簽名,則

.Body = body_ & .Body

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM