?
Solved

OLE Automate E-Mail/Notes Message

Posted on 2003-02-25
13
Medium Priority
?
308 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
13 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month11 days, 20 hours left to enroll

752 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