2017-05-18 6 views
0

Ich habe derzeit ein kleines Codesegment, um E-Mails vorab zu befüllen und das aktuelle Arbeitsblatt anzuhängen. Was ich fertigstellen muss, ist auch, einen Standardkörper hinzuzufügen, hier ist mein Code unten;E-Mail-Nachrichtentext über Lotus Notes ausfüllen - Excel VBA

Sub SDFMail() 

Dim name As Variant 
Dim subj As Variant 

name = InputBox("Please enter name of requestor") 
subj = InputBox("Please enter the subject of the service ticket") 
dias = InputBox("Please enter the date in the following format DD-MM-YYYY") 

    Dim strrecipient As String: strrecipient = "[email protected]" 
    Dim strsubject As String: strsubject = subj & " - " & name & " - " & dias 

    Application.Dialogs(xlDialogSendMail).Show arg1:=strrecipient, arg2:=strsubject 

End Sub 

Vielen Dank für Ihre Hilfe,

Best,

A

Antwort

0

Sie werden nicht viel von Optionen haben, wenn Sie Dialoge verwenden. Verwenden Sie den folgenden Code, damit Sie alles problemlos steuern können.

Kopieren Sie den Code und fügen Sie ihn in ein Modul ein und führen Sie ihn aus. Wenn Sie das brauchen, drücken Sie bitte das Häkchen neben dieser Frage;)

Sub SDFMail() 
    Dim strSubject As String 
    Dim strRecipient As String 
    Dim name As String 
    Dim subj As String 
    Dim dias As String 

    Dim outlook As Object 
    Dim outlookMail As Object 

    'Define outlook object 
    Set outlook = CreateObject("Outlook.Application") 
    Set outlookMail = outlook.CreateItem(0) 

    'Get the info from the user 
    name = InputBox("Please enter name of requestor") 
    subj = InputBox("Please enter the subject of the service ticket") 
    dias = InputBox("Please enter the date in the following format DD-MM-YYYY") 

    'Format subject 
    strRecipient = "[email protected]" 
    strSubject = subj & " - " & name & " - " & dias 

    'Save the workbook 
    ThisWorkbook.Save 

    'populate then New Email attributes 
    With outlookMail 
     .To = strRecipient 
     .CC = "[email protected]" 
     .BCC = "[email protected]" 
     .Subject = strSubject 
     .Body = "This is a default body text." 
     .Attachments.Add ThisWorkbook.FullName 
     .Display 
    End With 

End Sub