ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sending Email using Lotus Notes (https://www.excelbanter.com/excel-programming/272967-sending-email-using-lotus-notes.html)

Bob[_26_]

Sending Email using Lotus Notes
 
Hello,

Can anybody give me an idea or tips on how to create a VBA
or macro code sending an email using Lotus Notes R5.

I would appreciate very much your help.

Thanks
Bob


Alex@JPCS

Sending Email using Lotus Notes
 
Bob,
I posted this in mid June - hope it helps

Sub Send_ETCMail()

Dim oSess As Object, msg As String
Dim oDB As Object
Dim oDoc As Object
Dim oItem As Object
Dim direct As Object
Dim var As Variant
Dim flag As Boolean

On Error GoTo Error1
Set oSess = CreateObject("notes.notessession")
Set oDB = oSess.getdatabase("SERVER NAME HERE", "")
Call oDB.openmail
flag = True

With ThisWorkbook.Sheets("Send Parameters") 'I set up a
datalist in the workbook for this
AttachPath = .Range("AttachPath") 'You can do
this with text
AttachName = .Range("AttachName") '
To_Address = .Range("To_Address") '
To_Name = .Range("To_Name") '
InstrText = .Range("InstrText") '
End With
AttachFile = AttachPath & "/" & AttachName

msg0 = "AUTOMATED MESSAGE TEXT IF DESIRED"
If Not (oDB.IsOpen) Then flag = oDB.Open("", "")
If Not flag Then
MsgBox "Cant't open mail file: " & oDB.server & " " &
oDB.FilePath
GoTo Error1
End If

Set oDoc = oDB.createdocument
Set oItem = oDoc.createrichtextitem("BODY")
oDoc.Form = "Memo"
oDoc.Subject = "Estimate To Complete File for Review"

oItem.appendtext ("ETC File Attachment")
oItem.addnewline (2)

On Error GoTo err02
oItem.embedObject 1454, "", AttachFile, "mail.rtf"

S001:
If rtn01 = vbOK Then msg = NoAttach_msg & msg
oDoc.sendto = To_Address
oDoc.body = msg0
oDoc.postdate = Date
oDoc.SaveMessageOnSend = True
oDoc.Send False
Exit Sub
Error1:
On Error Resume Next
MsgBox "Error in Lotus Notes Email Script"
Set oItem = Nothing
Set oDoc = Nothing
Set oDB = Nothing
Set oSess = Nothing
Exit Sub

err02:
Err.Clear
msg1 = "Attachment: [" & AttachName & "]" & " Was Not
Found in" & vbCrLf & " Directory: [" & AttachPath & "]"
msg1 = msg1 & vbCrLf & vbCrLf
msg1 = msg1 & "Do you wish to send advisory email without
attachment?"
rtn01 = MsgBox(msg1, vbCritical + vbOKCancel, "PSR SendMail
Utility")
If rtn01 = vbOK Then Resume S001
msg2 = "SendMail Routine Aborted for Recipient:" & vbCrLf &
" [" & To_Address & "]"
rtn02 = MsgBox(msg2, vbOKOnly, "PSR SendMail Utility")
End Sub



"Bob" wrote in message
...
Hello,

Can anybody give me an idea or tips on how to create a VBA
or macro code sending an email using Lotus Notes R5.

I would appreciate very much your help.

Thanks
Bob





All times are GMT +1. The time now is 02:31 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com