您的位置:首页 > 编程语言 > VB

How to send Lotus Notes mail messages with Microsoft Visual Basic

2010-03-22 20:48 525 查看
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
  
  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息