VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Generate Lotus Notes E-mail w/ embedded attachment using Visual Basic

by Todd Walling (3 Submissions)
Category: Internet/HTML
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Wed 21st March 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Generate Lotus Notes E-mail w/ embedded attachment using Visual Basic

API Declarations


' Declare local variables

Dim l_db As Database
Dim l_SendTo As String
Dim l_Subject As String
Dim l_Body As String

' Declare Notes COM variables

Dim n_session As New NotesSession
Dim n_dir As NotesDbDirectory
Dim n_db As NotesDatabase
Dim n_doc As NotesDocument
Dim n_object As NotesEmbeddedObject
Dim n_rtitem As NotesRichTextItem

Rate Generate Lotus Notes E-mail w/ embedded attachment using Visual Basic



'Works well and is very easy to manipulate!

Function SendNotesMail(p_SendTo As String, _ 
                       p_Subject As String, _
                       p_Body As String, _
                       p_Path As String, _
                       p_NotesPassword As String)
    '==========================================================
    ' Set database
    '==========================================================
    Set l_db = CurrentDb
    
    '==========================================================
    ' Create and initialize Lotus Notes Session
    '==========================================================
    Call n_session.Initialize(p_NotesPassword)
    
    '==========================================================
    ' Set Notes Session
    '==========================================================
    Set n_dir = n_session.GetDbDirectory("")
        
    '==========================================================
    ' Open Mail Database
    '==========================================================
    Set n_db = n_dir.OpenMailDatabase
        
    '==========================================================
    ' Create Mail Document
    '==========================================================
    Set n_doc = n_db.CreateDocument
        
    '==========================================================
    ' Create Form value
    '==========================================================
    Call n_doc.AppendItemValue("Form", "Memo")
    
    '==========================================================
    ' Create SendTo value - person receiving e-mail
    '==========================================================
    Call n_doc.AppendItemValue("SendTo", p_SendTo)
    
    '==========================================================
    ' Create Subject value
    '==========================================================
    Call n_doc.AppendItemValue("Subject", p_Subject)
        
    '==========================================================
    ' Create Body value
    '==========================================================
    Set n_rtitem = n_doc.CreateRichTextItem("Body")
    Call n_doc.AppendItemValue("Body", p_Body)
       
    '==========================================================
    ' Embed Attachment to Body 
    '==========================================================
    Set n_object = n_rtitem.EmbedObject(EMBED_ATTACHMENT, "", p_Path)
        
    '==========================================================
    ' Send Email document
    '==========================================================
    Call n_doc.Send(False)
    
    '==========================================================
    ' Give user message
    '==========================================================
    MsgBox "The e-mail has been sent to " & p_SendTo & ".", vbOKOnly
    
    '==========================================================
    ' Clean up objects
    '==========================================================
    Set l_db = Nothing
    Set n_db = Nothing
    
End Function


Download this snippet    Add to My Saved Code

Generate Lotus Notes E-mail w/ embedded attachment using Visual Basic Comments

No comments have been posted about Generate Lotus Notes E-mail w/ embedded attachment using Visual Basic. Why not be the first to post a comment about Generate Lotus Notes E-mail w/ embedded attachment using Visual Basic.

Post your comment

Subject:
Message:
0/1000 characters