1
votes

I Have a Excel VBA script that read Data from a sheet and automatically make a Lotus Notes Email. The script works fine but now i like to add a ExpiryTime or ExpiryDate to the Email but i dont find the field for that.

I Hobe u can help me with that.

        Set Maildb = Session.GETDATABASE(Mailserver, Mailkonto)
     If Maildb.IsOpen = True Then
          'Fertig zum mailen!
     Else
         Maildb.OPENMAIL
     End If

     'Ein neues Maildokument erstellen
    Set MailDoc = Maildb.CREATEDOCUMENT
    MailDoc.Form = "Memo"
    'Mail Empfänger, CC, BCC, übergeben.
    Set SendItem = MailDoc.APPENDITEMVALUE("SendTo", "")
    Set NCopyItem = MailDoc.APPENDITEMVALUE("CopyTo", "")
    Set BlindCopyToItem = MailDoc.APPENDITEMVALUE("BlindCopyTo", "")

    MailDoc.sendto = strEmpfaenger
    MailDoc.CopyTo = strcc
    MailDoc.BlindCopyTo = strbcc


'Dim exDate As New NotesDateTime (" ")
'Dim Expiretime
'Expiretime = DateAdd("h", 8, NowTime)

'Set ExpiryTime = MailDoc.APPENDITEMVALUE("Expiration", "")
'MailDoc.ExpiryTime = Today + 1095
'MailDoc.ExpiryTime = DateAdd("m", 5, Now)
'MailDoc.ExpiryTime = Now + DateSerial(0, 0, 2)
'MailDoc.ExpiryTime = Expiretime


    'Betreff Texte Übergeben,
    MailDoc.Subject = strBetreff
    'Mail Text übergeben.
    Set rtitem = MailDoc.CREATERICHTEXTITEM("Body")
    'MailDoc.body = strText
    'Anhang einfügen.
    Call rtitem.EMBEDOBJECT(1454, "", strFilename)
    MailDoc.SAVEMESSAGEONSEND = SaveIt

    'Mail Body Text mit Signatur.
    Signature = Maildb.GetProfileDocument("CalendarProfile").GetItemValue("Signature")(0)
    MailDoc.Body = strText & Signature
    'Mail erstellen
    Dim workspace As Object
    Set workspace = CreateObject("Notes.NOTESUIWORKSPACE")

    Dim notesUIDoc As Object
    Set notesUIDoc = workspace.EDITDOCUMENT(True, MailDoc)

'notesUIDoc.ExpiryTime = DateAdd("m", 5, Now)
'notesUIDoc.ExpiryTime = Now + DateSerial(0, 0, 2)
'notesUIDoc.ExpiryTime = Expiretime


    'Body Text löschen wegen doppelten Signatur Problem
    Call notesUIDoc.GOTOFIELD("Body")
    Call notesUIDoc.FieldClear("Body")
    Call notesUIDoc.FieldClear("Footer")
    'Body Text + Signatur einfügen
    Call notesUIDoc.FieldAppendText("Body", MailDoc.Body)
    Call notesUIDoc.EDITDOCUMENT(True, MailDoc).GOTOFIELD("Body")

    MsgBox ("Die Mail wurde erstellt")

        'Aufräumen
    Set Maildb = Nothing
    Set MailDoc = Nothing
    Set Session = Nothing
    Set EmbedObj = Nothing
'######################################################################################
End Function
2

2 Answers

1
votes

The name of the field is ExpireDate.

This code line sets the ExpireDate to e.g. 10 days in the future:

MailDoc.ExpireDate = Session.Evaluate("@Adjust(@Now; 0; 0; 10; 0; 0; 0)")
0
votes

With

MailDoc.ExpireDate = exDate 'Date from Excel

ist work very well. It dident show the expireDate by creating the mail but that isent a problem.

The problem is that the ExpirdeDate dident show in the receiving mail.

In the Lotus Notes Mail Overview the Mail is marked as expire and has also the rigth expirdeDate (In Eigenschaften-> ... ->ExpirdeDate. But when the mail will by open the expireDate doenst show in the Mail properties. Like Diese Email läuft ab ....

I hope u can help me a second time ;-)