?
Solved

OLE Automate E-Mail/Notes Message

Posted on 2003-02-25
13
Medium Priority
?
311 Views
Last Modified: 2013-12-18
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 ??
0
Comment
Question by:Exie
  • 4
  • 3
  • 2
9 Comments
 
LVL 7

Accepted Solution

by:
scottrma earned 200 total points
ID: 8022313
Try this:

Dim session As Object
Dim db As Object
Dim memo As Object

Set session = CreateObject("Notes.NotesSession")
Set db = session.GetDatabase("","")
Call db.OpenMail
Set memo = db.CreateDocoument()
memo.Form = "Memo"
memo.Subject = "E-Mail Notice"
memo.Body = "This is the body"
memo.SendTo = "bob@nowhere.com"
Call memo.Send(False)
0
 

Author Comment

by:Exie
ID: 8022348
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 ??
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 8025930
GetDatabase("","") is not correct

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

~Hemanth
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 8025935
0
 
LVL 7

Expert Comment

by:scottrma
ID: 8030265
Sorry, yes, put your Notes mail server and path to your mail database as arguments to the GetDatabase() call.

Regards,

Scott
0
 

Author Comment

by:Exie
ID: 8067489
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
0
 
LVL 7

Expert Comment

by:scottrma
ID: 8068266
Great to hear you found a solution!

Regards,

Scott
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 12238525
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 !
0
 
LVL 24

Assisted Solution

by:HemanthaKumar
HemanthaKumar earned 200 total points
ID: 12399997
Scott propose a script soln...

then I corrected it with this comment
>GetDatabase("","") is not correct

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

And follow the last script provided by the asker... code corrected with directions from both of us.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
Suggested Courses

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question