Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as VB.Net by Jochen ( 14 years ago )
'
Public Function sendNotesMail(SendToAddress() As String, Title As String, _
                              Body As String, _
                              Optional URLForAttachedFile As String = "null", _
                              Optional SendToCC As String = "null", _
                              Optional Header As String = "null", _
                              Optional Footer As String = "null") As Boolean
    'LOTUS OBJECTS
    'Dim oSession As NotesSession
    Dim oSession As Object
    'Dim oLotusDB As NotesDatabase
    Dim oLotusDB As Object
    'Dim oMailDoc As NotesDocument
    Dim oMailDoc As Object
    'LOTUS VALUE BUFFERS
    'Settings
    Dim oSettingsBuffer As Object
    'Text
    Dim oDataBuffer As Object
    'Attachment RichData
    Dim oAttachmentRT As Object
    'Attachment Embedded object
    Dim oAttachment As Object
    'LOTUS CONSTANTS
    Const EMBED_ATTACHMENT As Integer = 1454
    '
    'CREATE NOTES SESSION OBJECT
    Set oSession = CreateObject("Notes.NotesSession")
    'INITIALIZE DATABASE AND LINK TO THIS SESSION, (server, file) both blank, since we will be loading our database)
    Set oLotusDB = oSession.GetDatabase("", "")
    'OPEN MAIL DATABASE
    oLotusDB.OPENMAIL
    'CREATE NEW DOCUMENT IN THE DB
    Set oMailDoc = oLotusDB.CreateDocument
    'APPEND SUBJECT
    Set oSettingsBuffer = oMailDoc.AppendItemValue("Subject", Title)
    'SET DOCUMENT FORMAT TO MEMO
    Set oSettingsBuffer = oMailDoc.AppendItemValue("Form", "Memo")
    'APPEND RECIPIENT
    Set oSettingsBuffer = oMailDoc.AppendItemValue("SendTo", SendToAddress)
    'APPEND CC
    If (SendToCC <> "null") Then
        Set oSettingsBuffer = oMailDoc.AppendItemValue("CopyTo", SendToCC)
    End If
    'CREATE BODY
    Set oDataBuffer = oMailDoc.CreateRichTextItem("Body")
    '
    'APPEND HEADER TO BODY
    If (Header <> "null") Then
        oDataBuffer.AppendText (Header & Chr(13))
    End If
    'APPEND TEXT TO BODY
    oDataBuffer.AppendText (Body)
    'APPEND FOOTER TO BODY
    If (Footer <> "null") Then
        oDataBuffer.AppendText (Chr(13) & Footer)
    End If
    '
    'APPEND ATTACHMENT
    If (URLForAttachedFile <> "null") Then
        Set oAttachmentRT = oMailDoc.CreateRichTextItem("Attachment")
        Set oAttachment = oAttachmentRT.EmbedObject(EMBED_ATTACHMENT, "", URLForAttachedFile)
    End If
    '
    '
    'USE DOCUMENT OBJECT TO SEND THE EMAIL
    oMailDoc.Send (False)
    '
    'CLEAN UP
    Set oDataBuffer = Nothing
    Set oSettingsBuffer = Nothing
    Set oMailDoc = Nothing
    Set oLotusDB = Nothing
    Set oSession = Nothing
    '
    'RETURN VALUE
    sendNotesMail = True
End Function

 

Revise this Paste

Parent: 49498
Children: 49500
Your Name: Code Language: