Link to home
Start Free TrialLog in
Avatar of Exie
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 ??
ASKER CERTIFIED SOLUTION
Avatar of scottrma
scottrma

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Exie
Exie

ASKER

Ooo .... It looks good!

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 ??
GetDatabase("","") is not correct

It should be
GetDatabase("ServerName","FilePath")

~Hemanth
Sorry, yes, put your Notes mail server and path to your mail database as arguments to the GetDatabase() call.

Regards,

Scott
Avatar of Exie

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.NotesSession")

  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
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
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial