如何在 Outlook 模板中更改具有多个输入框的主题行?

问题描述 投票:0回答:1

我是 makros 新手。我经常使用电子邮件模板,目前有一个静态主题行,我必须在其中更改多个占位符,比如“编号、地点、日期”。

有没有一种方法可以打开模板,然后打开一个输入框,询问号码,然后打开第二个输入框,询问地点,依此类推?

如果可以的话,在我“okay”最后一个输入框后,应该直接发送电子邮件。

过去两个小时我一直在寻找方法,但没有找到我的具体问题的答案。

我试过这个:

Private Sub Application_ItemLoad(ByVal Item As Object)
    On Error Resume Next
    If Item.Class = olMail Then
        If Item.Subject = "DeineVorlagenName" Then
            Dim customSubjectPart1 As String
            Dim customSubjectPart2 As String
            Dim customSubjectPart3 As String
            
            customSubjectPart1 = InputBox("Gib den ersten Teil des Betreffs ein:")
            If customSubjectPart1 <> "" Then
                customSubjectPart2 = InputBox("Gib den zweiten Teil des Betreffs ein:")
                If customSubjectPart2 <> "" Then
                    customSubjectPart3 = InputBox("Gib den dritten Teil des Betreffs ein:")
                    If customSubjectPart3 <> "" Then
                        Dim combinedSubject As String
                        combinedSubject = customSubjectPart1 & " - " & customSubjectPart2 & " - " & customSubjectPart3
                        
                        Item.Subject = combinedSubject
                        Item.Send ' Automatisches Senden der E-Mail nach Bestätigung der letzten InputBox
                    End If
                End If
            End If
        End If
    End If
End Sub
vba outlook
1个回答
0
投票

使用

CreateItemFromTemplate
,您就知道邮件是正确的。

模板中无需主题即可确保它是您想要的主题。

Option Explicit

Private Sub createDVNfromTemplate()
    
    Dim DVN As MailItem
    
    'On Error Resume Next    ' Disable debugging. Enable confusion.
    
    ' change C:\Users\brian\AppData\Roaming\Microsoft\Templates\ as appropriate
    Set DVN = CreateItemFromTemplate("C:\Users\brian\AppData\Roaming\Microsoft\Templates\DeineVorlagenName.oft")
    
    Dim customSubjectPart1 As String
    Dim customSubjectPart2 As String
    Dim customSubjectPart3 As String
    Dim combinedSubject As String
    
    'If DVN.Subject = "DeineVorlagenName" Then  ' Unnecessary with CreateItemFromTemplate
    
        customSubjectPart1 = InputBox("Gib den ersten Teil des Betreffs ein:")
            
        If customSubjectPart1 <> "" Then
            customSubjectPart2 = InputBox("Gib den zweiten Teil des Betreffs ein:")
                
            If customSubjectPart2 <> "" Then
                customSubjectPart3 = InputBox("Gib den dritten Teil des Betreffs ein:")
                    
                If customSubjectPart3 <> "" Then
                    combinedSubject = customSubjectPart1 & " - " & customSubjectPart2 & " - " & customSubjectPart3
                    
                    DVN.Subject = combinedSubject
                    
                    DVN.Display
                    ' DVN.Send ' Automatisches Senden der E-Mail nach Bestätigung der letzten InputBox
                        
                End If
            End If
                
        End If
        
    'End If
    
End Sub
© www.soinside.com 2019 - 2024. All rights reserved.