|
-
October 12th, 2004, 04:28 AM
#1
E-mail with VB code on Lotus Notes
Hi,
Can somebody help me on sending E-mail through VB code.I have seen the posting of sending an E-mail through VB6.0 when we are using Microsoft Outlook,however we sue Lotus notes to send and receive mails.
What kind of changes would be required in the code mentioned below when Lotus Notes is being used for mails.
Dim objOutlook As Object
Dim objOutlookMsg As Object
Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(0)
With objOutlookMsg
.To = "[email protected]
.Cc = "[email protected]"
.Subject = "Hello World (one more time)..."
.Body = "This is the body of message"
.HTMLBody = "HTML version of message"
.Attachments.Add ("c:\myFileToSend.txt")
.Send 'Let´s go!
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
-
October 12th, 2004, 06:30 AM
#2
Re: E-mail with VB code on Lotus Notes
Here's some code that one of guys set up a couple of years ago, which was never used, and he's no longer here, so I can't state how correct it is:
He has a reference to Lotus Domino Objects (DOMOBJ.TLB)
He sets Params.MAIL_PASSWORD from a value in a ini file.
Code:
Private Sub SendMail(strRecipient As String, strSubject As String, strFileName As String)
Dim ns As NotesSession
Dim nDB As NotesDatabase
Dim nDoc As NotesDocument
Dim nDir As NotesDbDirectory
Dim nRTItem As NotesRichTextItem
Dim MsgFile As Integer
Dim strBuf As String
'
' create a notes session and initialize it with the password taken from the ini file
'
Set ns = New NotesSession
ns.Initialize Params.MAIL_PASSWORD
'
' get the database listing from the server and then open the default mail database for that profile
'
Set nDir = ns.GetDbDirectory("")
Set nDB = nDir.OpenMailDatabase()
'
' create a notes Memo document and set the subject and SendTo fields
'
Set nDoc = nDB.CreateDocument
nDoc.ReplaceItemValue "SendTo", strRecipient
nDoc.ReplaceItemValue "Subject", strSubject
'
' set the "Body" field of the mail to be a RichText field
' This will allow the insertion of carriage returns using AddNewLine
'
Set nRTItem = nDoc.CreateRichTextItem("Body")
'
' Transfer the text from the file into the "Body" field of the e-mail line by line
'
If Dir(strFileName) <> "" Then
'
' get the next free file handle
MsgFile = FreeFile
' open the specified file
Open strFileName For Input As MsgFile
' write each line of the file to the mail and add a carriage return after each line
Do Until EOF(MsgFile)
Input #MsgFile, strBuf
nRTItem.AppendText (strBuf)
nRTItem.AddNewLine (1)
Loop
' close the file
Close MsgFile
Else
'
' if the msgfile was empty then just stick in a note to say so.
strBuf = "No Earlpay information today."
nRTItem.AppendText strBuf
End If
'
' send the mail
'
nDoc.Send (False)
'
' tidy up
'
Set nDoc = Nothing
Set nRTItem = Nothing
Set nDir = Nothing
Set nDB = Nothing
Set ns = Nothing
End Sub
HTH
JP
Please remember to rate all postings. 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|