How to send Lotus Notes mail messages with Microsoft Visual Basic

Question
Customers with Microsoft® Visual Basic (VB) or VB.NET applications might want to integrate Lotus Notes® e-mail functionality. Is there an example of how to create a Notes® e-mail from Visual Basic?
 
 
Answer
The following Microsoft Visual Basic 6 (VB6) code sends a Notes e-mail message. It includes examples of code to include an attachment and to save the sent message, which are both optional and can be removed if desired.

IMPORTANT NOTE: This is sample code, provided only to illustrate one way to approach this issue. IBM Support will not be able to customize this script for a customer's own configuration. While this may work for some customers it is offered as a suggestion only, and is not something that IBM Lotus software supports further.

  • Dim Maildb As Object
    Dim MailDoc As Object
    Dim Body As Object
    Dim Session As Object
    'Start a session to notes
    Set Session = CreateObject("Lotus.NotesSession")
    'This line prompts for password of current ID noted in Notes.INI
    Call Session.Initialize
    'or use below to supply password of the current ID
    'Call Session.Initialize("<password>")
    'Open the mail database in notes
    Set Maildb = Session.GETDATABASE("", "c:/notes/data/mail/mymail.nsf")
    If Not Maildb.IsOpen = True Then
    Call Maildb.Open
    End If
    'Create the mail document
    Set MailDoc = Maildb.CREATEDOCUMENT
    Call MailDoc.ReplaceItemValue("Form", "Memo")
    'Set the recipient
    Call MailDoc.ReplaceItemValue("SendTo", "John Doe")
    'Set subject
    Call MailDoc.ReplaceItemValue("Subject", "Subject Text")
    'Create and set the Body content
    Set Body = MailDoc.CREATERICHTEXTITEM("Body")
    Call Body.APPENDTEXT("Body text here")
    'Example to create an attachment (optional)
    Call Body.ADDNEWLINE(2)
    Call Body.EMBEDOBJECT(1454, "", "C:/filename", "Attachment")
    'Example to save the message (optional)
    MailDoc.SAVEMESSAGEONSEND = True
    'Send the document
    'Gets the mail to appear in the Sent items folder
    Call MailDoc.ReplaceItemValue("PostedDate", Now())
    Call MailDoc.SEND(False)
    'Clean Up
    Set Maildb = Nothing
    Set MailDoc = Nothing
    Set Body = Nothing
    Set Session = Nothing

Note: The Visual Basic programmer needs to set the Reference to use Lotus Domino® objects prior to implementing this function. To enable the Lotus Notes classes to appear in the Visual Basic browser, you must execute the following within VB: Select Tools, References and select the checkbox for 'Lotus Notes Automation Classes'.
 
 
 
 
Cross Reference information
SegmentProductComponentPlatformVersionEdition
Messaging ApplicationsLotus NotesLotus NotesWindows8.0, 7.0, 6.5, 6.0, 5.0All Editions
 
 
Question
Customers with Microsoft® Visual Basic (VB) or VB.NET applications might want to integrate Lotus Notes® e-mail functionality. Is there an example of how to create a Notes® e-mail from Visual Basic?
 
 
Answer
The following Microsoft Visual Basic 6 (VB6) code sends a Notes e-mail message. It includes examples of code to include an attachment and to save the sent message, which are both optional and can be removed if desired.

IMPORTANT NOTE: This is sample code, provided only to illustrate one way to approach this issue. IBM Support will not be able to customize this script for a customer's own configuration. While this may work for some customers it is offered as a suggestion only, and is not something that IBM Lotus software supports further.

  • Dim Maildb As Object
    Dim MailDoc As Object
    Dim Body As Object
    Dim Session As Object
    'Start a session to notes
    Set Session = CreateObject("Lotus.NotesSession")
    'This line prompts for password of current ID noted in Notes.INI
    Call Session.Initialize
    'or use below to supply password of the current ID
    'Call Session.Initialize("<password>")
    'Open the mail database in notes
    Set Maildb = Session.GETDATABASE("", "c:/notes/data/mail/mymail.nsf")
    If Not Maildb.IsOpen = True Then
    Call Maildb.Open
    End If
    'Create the mail document
    Set MailDoc = Maildb.CREATEDOCUMENT
    Call MailDoc.ReplaceItemValue("Form", "Memo")
    'Set the recipient
    Call MailDoc.ReplaceItemValue("SendTo", "John Doe")
    'Set subject
    Call MailDoc.ReplaceItemValue("Subject", "Subject Text")
    'Create and set the Body content
    Set Body = MailDoc.CREATERICHTEXTITEM("Body")
    Call Body.APPENDTEXT("Body text here")
    'Example to create an attachment (optional)
    Call Body.ADDNEWLINE(2)
    Call Body.EMBEDOBJECT(1454, "", "C:/filename", "Attachment")
    'Example to save the message (optional)
    MailDoc.SAVEMESSAGEONSEND = True
    'Send the document
    'Gets the mail to appear in the Sent items folder
    Call MailDoc.ReplaceItemValue("PostedDate", Now())
    Call MailDoc.SEND(False)
    'Clean Up
    Set Maildb = Nothing
    Set MailDoc = Nothing
    Set Body = Nothing
    Set Session = Nothing

Note: The Visual Basic programmer needs to set the Reference to use Lotus Domino® objects prior to implementing this function. To enable the Lotus Notes classes to appear in the Visual Basic browser, you must execute the following within VB: Select Tools, References and select the checkbox for 'Lotus Notes Automation Classes'.
 
 
 
 
Cross Reference information
SegmentProductComponentPlatformVersionEdition
Messaging ApplicationsLotus NotesLotus NotesWindows8.0, 7.0, 6.5, 6.0, 5.0All Editions
 
 
Question
Customers with Microsoft® Visual Basic (VB) or VB.NET applications might want to integrate Lotus Notes® e-mail functionality. Is there an example of how to create a Notes® e-mail from Visual Basic?
 
 
Answer
The following Microsoft Visual Basic 6 (VB6) code sends a Notes e-mail message. It includes examples of code to include an attachment and to save the sent message, which are both optional and can be removed if desired.

IMPORTANT NOTE: This is sample code, provided only to illustrate one way to approach this issue. IBM Support will not be able to customize this script for a customer's own configuration. While this may work for some customers it is offered as a suggestion only, and is not something that IBM Lotus software supports further.

  • Dim Maildb As Object
    Dim MailDoc As Object
    Dim Body As Object
    Dim Session As Object
    'Start a session to notes
    Set Session = CreateObject("Lotus.NotesSession")
    'This line prompts for password of current ID noted in Notes.INI
    Call Session.Initialize
    'or use below to supply password of the current ID
    'Call Session.Initialize("<password>")
    'Open the mail database in notes
    Set Maildb = Session.GETDATABASE("", "c:/notes/data/mail/mymail.nsf")
    If Not Maildb.IsOpen = True Then
    Call Maildb.Open
    End If
    'Create the mail document
    Set MailDoc = Maildb.CREATEDOCUMENT
    Call MailDoc.ReplaceItemValue("Form", "Memo")
    'Set the recipient
    Call MailDoc.ReplaceItemValue("SendTo", "John Doe")
    'Set subject
    Call MailDoc.ReplaceItemValue("Subject", "Subject Text")
    'Create and set the Body content
    Set Body = MailDoc.CREATERICHTEXTITEM("Body")
    Call Body.APPENDTEXT("Body text here")
    'Example to create an attachment (optional)
    Call Body.ADDNEWLINE(2)
    Call Body.EMBEDOBJECT(1454, "", "C:/filename", "Attachment")
    'Example to save the message (optional)
    MailDoc.SAVEMESSAGEONSEND = True
    'Send the document
    'Gets the mail to appear in the Sent items folder
    Call MailDoc.ReplaceItemValue("PostedDate", Now())
    Call MailDoc.SEND(False)
    'Clean Up
    Set Maildb = Nothing
    Set MailDoc = Nothing
    Set Body = Nothing
    Set Session = Nothing

Note: The Visual Basic programmer needs to set the Reference to use Lotus Domino® objects prior to implementing this function. To enable the Lotus Notes classes to appear in the Visual Basic browser, you must execute the following within VB: Select Tools, References and select the checkbox for 'Lotus Notes Automation Classes'.
 
 
 
 
Cross Reference information
SegmentProductComponentPlatformVersionEdition
Messaging ApplicationsLotus NotesLotus NotesWindows8.0, 7.0, 6.5, 6.0, 5.0All Editions
 
 
Question
Customers with Microsoft® Visual Basic (VB) or VB.NET applications might want to integrate Lotus Notes® e-mail functionality. Is there an example of how to create a Notes® e-mail from Visual Basic?
 
 
Answer
The following Microsoft Visual Basic 6 (VB6) code sends a Notes e-mail message. It includes examples of code to include an attachment and to save the sent message, which are both optional and can be removed if desired.

IMPORTANT NOTE: This is sample code, provided only to illustrate one way to approach this issue. IBM Support will not be able to customize this script for a customer's own configuration. While this may work for some customers it is offered as a suggestion only, and is not something that IBM Lotus software supports further.

  • Dim Maildb As Object
    Dim MailDoc As Object
    Dim Body As Object
    Dim Session As Object
    'Start a session to notes
    Set Session = CreateObject("Lotus.NotesSession")
    'This line prompts for password of current ID noted in Notes.INI
    Call Session.Initialize
    'or use below to supply password of the current ID
    'Call Session.Initialize("<password>")
    'Open the mail database in notes
    Set Maildb = Session.GETDATABASE("", "c:/notes/data/mail/mymail.nsf")
    If Not Maildb.IsOpen = True Then
    Call Maildb.Open
    End If
    'Create the mail document
    Set MailDoc = Maildb.CREATEDOCUMENT
    Call MailDoc.ReplaceItemValue("Form", "Memo")
    'Set the recipient
    Call MailDoc.ReplaceItemValue("SendTo", "John Doe")
    'Set subject
    Call MailDoc.ReplaceItemValue("Subject", "Subject Text")
    'Create and set the Body content
    Set Body = MailDoc.CREATERICHTEXTITEM("Body")
    Call Body.APPENDTEXT("Body text here")
    'Example to create an attachment (optional)
    Call Body.ADDNEWLINE(2)
    Call Body.EMBEDOBJECT(1454, "", "C:/filename", "Attachment")
    'Example to save the message (optional)
    MailDoc.SAVEMESSAGEONSEND = True
    'Send the document
    'Gets the mail to appear in the Sent items folder
    Call MailDoc.ReplaceItemValue("PostedDate", Now())
    Call MailDoc.SEND(False)
    'Clean Up
    Set Maildb = Nothing
    Set MailDoc = Nothing
    Set Body = Nothing
    Set Session = Nothing

Note: The Visual Basic programmer needs to set the Reference to use Lotus Domino® objects prior to implementing this function. To enable the Lotus Notes classes to appear in the Visual Basic browser, you must execute the following within VB: Select Tools, References and select the checkbox for 'Lotus Notes Automation Classes'.
 
 
 
 
Cross Reference information
SegmentProductComponentPlatformVersionEdition
Messaging ApplicationsLotus NotesLotus NotesWindows8.0, 7.0, 6.5, 6.0, 5.0All Editions
 
 

Question
Customers with Microsoft® Visual Basic (VB) or VB.NET applications might want to integrate Lotus Notes® e-mail functionality. Is there an example of how to create a Notes® e-mail from Visual Basic? 
 
 
Answer
The following Microsoft Visual Basic 6 (VB6) code sends a Notes e-mail message. It includes examples of code to include an attachment and to save the sent message, which are both optional and can be removed if desired.
IMPORTANT NOTE: This is sample code, provided only to illustrate one way to approach this issue. IBM Support will not be able to customize this script for a customer's own configuration. While this may work for some customers it is offered as a suggestion only, and is not something that IBM Lotus software supports further.


Dim Maildb As Object
Dim MailDoc As Object
Dim Body As Object
Dim Session As Object
'Start a session to notes
Set Session = CreateObject("Lotus.NotesSession")
'This line prompts for password of current ID noted in Notes.INI
Call Session.Initialize
'or use below to supply password of the current ID
'Call Session.Initialize("<password>")
'Open the mail database in notes
Set Maildb = Session.GETDATABASE("", "c:/notes/data/mail/mymail.nsf")
If Not Maildb.IsOpen = True Then
Call Maildb.Open
End If
'Create the mail document
Set MailDoc = Maildb.CREATEDOCUMENT
Call MailDoc.ReplaceItemValue("Form", "Memo")
'Set the recipient
Call MailDoc.ReplaceItemValue("SendTo", "John Doe")
'Set subject
Call MailDoc.ReplaceItemValue("Subject", "Subject Text")
'Create and set the Body content
Set Body = MailDoc.CREATERICHTEXTITEM("Body")
Call Body.APPENDTEXT("Body text here")
'Example to create an attachment (optional)
Call Body.ADDNEWLINE(2)
Call Body.EMBEDOBJECT(1454, "", "C:/filename", "Attachment")
'Example to save the message (optional)
MailDoc.SAVEMESSAGEONSEND = True
'Send the document
'Gets the mail to appear in the Sent items folder
Call MailDoc.ReplaceItemValue("PostedDate", Now())
Call MailDoc.SEND(False)
'Clean Up
Set Maildb = Nothing
Set MailDoc = Nothing
Set Body = Nothing
Set Session = Nothing

Note: The Visual Basic programmer needs to set the Reference to use Lotus Domino® objects prior to implementing this function. To enable the Lotus Notes classes to appear in the Visual Basic browser, you must execute the following within VB: Select Tools, References and select the checkbox for 'Lotus Notes Automation Classes'. 
 
 
 
 
 
 
Cross Reference information
Segment Product Component Platform Version Edition
Messaging Applications Lotus Notes Lotus Notes Windows 8.0, 7.0, 6.5, 6.0, 5.0 All Editions
  
  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值