0

好的,这是更新的版本......虽然仍然无法正常工作

        NextHTMLBody = nextMessage.HTMLBody
        NextHTMLBody = Replace(NextHTMLBody, "%Customer_Name%", bBodyName)
        NextHTMLBody = Replace(NextHTMLBody, "%##%", formPage.Controls("LoanNumber1").Value)

        With nextMessage
            .HTMLBody = NextHTMLBody
            .Subject = subjEmail
            .To = sendTo
            .Send
        End With

-------------在这里它有效..不确定我做了什么不同

        'Set body
        NextHTMLBody = nextMessage.HTMLBody
        NextHTMLBody = Replace(NextHTMLBody, "%Customer_Name%", bBodyName)
        NextHTMLBody = Replace(NextHTMLBody, "%##%", formPage.Controls("LoanNumber1").Value)

        With nextMessage
            .HTMLBody = NextHTMLBody
            '.Body = NextHTMLBody
            .Subject = subjEmail
            .To = sendTo
            '.Send
            .Display
        End With
4

1 回答 1

0

替换在这里应该可以正常工作:

If InStr(nextMessage.HTMLBody, "%Customer_Name%") <> 0 Then
    NextHTMLBody = Replace(nextMessage.Body, "%Customer_Name%", bBodyName)
End If

但是在下一个块中,您将放弃上面执行的替换,方法是返回nextMessage.HTMLBody而不是继续NextHTMLBody。您还切换到HTMLBodyfrom Body: 不确定是否有原因。

If InStr(nextMessage.HTMLBody, "%##%") <> 0 Then

    NextHTMLBody = Replace(nextMessage.HTMLBody, "%##%", _
                             formPage.Controls("LoanNumber1").Value)
End If

最好的选择更像是这样(你并不真的需要 If-Then 在这里):

NextHTMLBody = nextMessage.HTMLBody

NextHTMLBody = Replace(NextHTMLBody, "%Customer_Name%", bBodyName)

NextHTMLBody = Replace(NextHTMLBody, "%##%", _
                             formPage.Controls("LoanNumber1").Value)
于 2015-12-16T17:31:04.777 回答