Lotus Email
Finally its here...Copy the following code in a general module and call SendEmail function.
It returns 0 if successfull else error number is returned.
Public Function SendEmail(strMailTo As String, strSubject As String, strBodyText _ As String, blnReceipt As Boolean, Optional strAttachment As String, Optional _ strCCTo As String, Optional strBCCTo As String) As Long Dim objApp As Object Dim objMail As Object Dim objLotusDB As Object Dim objLotusItem As Object Dim arrAttachment() As String Dim strLotusUser As String Dim strLotusDb As String Dim intAttachCntr As Integer DoEvents On Error GoTo ErrHandler Set objApp = CreateObject("Notes.NotesSession") strLotusUser = objApp.UserName strLotusDb = Left$(strLotusUser, 1) & Right$(strLotusUser, (Len(strLotusUser) - InStr(1, strLotusUser, " "))) & ".nsf" Set objLotusDB = objApp.GETDATABASE("", strLotusDb) If Not objLotusDB.IsOpen Then objLotusDB.OPENMAIL End If Set objMail = objLotusDB.CREATEDOCUMENT Set objLotusItem = objMail.CREATERICHTEXTITEM("BODY") With objMail .Form = "Memo" .sendTo = Split(strMailTo, ",") If Len(strCCTo) > 0 Then .CopyTo = Split(strCCTo, ",") If Len(strBCCTo) > 0 Then .BlindCopyTo = Split(strBCCTo, ",") .Subject = strSubject .Principal = "Group mail box" .Body = strBodyText .posteddate = Now() If blnReceipt Then .ReturnReceipt = "1" .SaveMessageOnSend = True 'Attachments If Len(strAttachment) > 0 Then arrAttachment() = Split(strAttachment, ",") For intAttachCntr = 0 To UBound(arrAttachment, 1) Call objLotusItem.EmbedObject(1454, vbNullString, _ arrAttachment(intAttachCntr), "") Next intAttachCntr End If .Visible = True .Send False End With SendEmail = 0 'Success returned exitSendAttachment: Set objLotusDB = Nothing Set objLotusItem = Nothing Set objApp = Nothing Set objMail = Nothing Exit Function ErrHandler: SendEmail = Err.Number 'Error returned GoTo exitSendAttachment End Function Sub TestIt() If SendEmail("Email@abc.com", "Test Mail", "Email Body", True) = 0 Then MsgBox "Success" Else MsgBox "Failed" End If End Sub
»
- Vishesh's blog
- Login or register to post comments
- 15487 reads
Learn VBA
How to quick learn VBA?
Emails to cut
I've this issue with Lotus it save all to who I want to send but it send only to the first one.
Email's on TO are cut
I've an code like this.
When I send the email it store in Lotus all email's but it send only to the first email all other are cut.
Lotus mail automation
Works fine except it gives sender name as "Group mail box" instead of my lotus note id as sender.
Can you suggest how to incorporate my name in the sender ID
with regards
Sudeep
Dear vishesh The VBA module
Dear vishesh
The VBA module is working beautifully except 1 problem.My ID is not coming while sending mail.If you can help on the above matter.
Sudeep
Are there more than 1 email
Are there more than 1 email configured on Lotus ?
Lotus note automation
No,Only mine.
Do you have a contact no.
With regards
Sudeep
Another source
Check the following link as well:
http://www.excelitems.com/2011/01/send-lotus-notes-email-vba-excel.html