Exie
asked on
OLE Automate E-Mail/Notes Message
I have some VB style code that needs to send an E-Mail to someone once a job is finnished. I found some code which looks like so:
Sub DeliverEmail ( )
Dim session as new NotesSession
session.Initalize
if memo is nothing then
set memo = session.createDocument
memo.replaceItemValue "Form" , "Memo"
memo.replaceItemValue "Subject" , "E-Mail Notice"
memo.replaceItemValue "Body" , "Your reports are ready!"
end if
memo.replaceItemValue "SendTo" , "bob@nowhere.com"
mail.send false
End Sub
This simply doesnt work :( I get "NotesSession is not a record type"
Could someone give me a simple example of a Sub to send a 1 line E-Mail message ??
Sub DeliverEmail ( )
Dim session as new NotesSession
session.Initalize
if memo is nothing then
set memo = session.createDocument
memo.replaceItemValue "Form" , "Memo"
memo.replaceItemValue "Subject" , "E-Mail Notice"
memo.replaceItemValue "Body" , "Your reports are ready!"
end if
memo.replaceItemValue "SendTo" , "bob@nowhere.com"
mail.send false
End Sub
This simply doesnt work :( I get "NotesSession is not a record type"
Could someone give me a simple example of a Sub to send a 1 line E-Mail message ??
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
GetDatabase("","") is not correct
It should be
GetDatabase("ServerName"," FilePath")
~Hemanth
It should be
GetDatabase("ServerName","
~Hemanth
Here is the complete documentation on How to handle Domino as COM object
http://www-10.lotus.com/ldd/notesua.nsf/ddaf2e7f76d2cfbf8525674b00508d2b/6932e4fc0ea17542852569d9005bd01d?OpenDocument
http://www-10.lotus.com/ldd/notesua.nsf/ddaf2e7f76d2cfbf8525674b00508d2b/6932e4fc0ea17542852569d9005bd01d?OpenDocument
Sorry, yes, put your Notes mail server and path to your mail database as arguments to the GetDatabase() call.
Regards,
Scott
Regards,
Scott
ASKER
Thanks guys, I eventually got this code to work.
Sub SendNotesMail(Subject , Recipient , BodyText , SaveIt )
Dim Maildb as Object
Dim UserName
Dim MailDbName
Dim MailDoc as Object
Dim Session as Object
Set Session = CreateObject("Notes.NotesS ession")
UserName = Session.UserName
MailDbName = Left(UserName, 1) & Right(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
Set Maildb = Session.GETDATABASE("", MailDbName)
If Maildb.ISOPEN = True Then
Else
Maildb.OPENMAIL
End If
'Set up the new mail document
Set MailDoc = Maildb.CREATEDOCUMENT
MailDoc.Form = "Memo"
MailDoc.sendto = Recipient
MailDoc.Subject = Subjetc
MailDoc.Body = BodyText
MailDoc.SAVEMESSAGEONSEND = SaveIt
MailDoc.SEND 0, Recipient
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set Session = Nothing
Set EmbedObj = Nothing
end sub
Sub SendNotesMail(Subject , Recipient , BodyText , SaveIt )
Dim Maildb as Object
Dim UserName
Dim MailDbName
Dim MailDoc as Object
Dim Session as Object
Set Session = CreateObject("Notes.NotesS
UserName = Session.UserName
MailDbName = Left(UserName, 1) & Right(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
Set Maildb = Session.GETDATABASE("", MailDbName)
If Maildb.ISOPEN = True Then
Else
Maildb.OPENMAIL
End If
'Set up the new mail document
Set MailDoc = Maildb.CREATEDOCUMENT
MailDoc.Form = "Memo"
MailDoc.sendto = Recipient
MailDoc.Subject = Subjetc
MailDoc.Body = BodyText
MailDoc.SAVEMESSAGEONSEND = SaveIt
MailDoc.SEND 0, Recipient
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set Session = Nothing
Set EmbedObj = Nothing
end sub
Great to hear you found a solution!
Regards,
Scott
Regards,
Scott
Not sure I am hearing you right.. The soln was achieved and asker ignored to grade it... So the tips given by experts made him to nail the problem... So why points should be refunded ?? I think experts should be graded with points here !
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I ran it and made it as far as:
Set memo = db.CreateDocoument()
and it died with an error of "No Such property or method"
any thoughts ?
p.s. Do I need an .nsf file to put into the GetDatabase() call ??