Link to home
Start Free TrialLog in
Avatar of rabbani
rabbani

asked on

Is this possible with Lotus Notes

I have a report in a gif format on the C:\ Drive as "C:\Report.gif". I have an asp page which has a "Send Report by E-Mail" button. On the click of this button, I have to open the Lotus Notes e-mail with a new memo and embed this Report.gif in the body of the new Memo and display it.

The user will then add the To, CC, addresses and some message in the e-mail body below or above the Report.gif and then will hit the send button.

I appreciate if any one can let me know if this is possible.

Thanks,
Rabbani
Avatar of qwaletee
qwaletee

Yes, this is possible.

You can do this one of two ways:

1) Use the ASP to build an SMTP message to send to Domino, it will accept and display it just fine

2) Or, you may access the Notes object model from within ASP to create the message

For 1, you just have to know how to create the SMTP message, and which Domio server will acept SMTP messages for you

For 2, you have several ways of accessing the object model...
2a) Install a Notes client or a Domino server on the same box your ASP will run on, then use CreateObject to access the object nodel

2b) Access the object model remotely on a Domino server via CORBA

2a is probably more attarctive than 2b, because 2b means adding a "third party" to this dance: a CORBA library of some sort for your ASP to call.  The only advantage of 2b is that it does notrequire any Lotus binaries on your ASP box.

Otherwise, the two approaches are more or less the same.
ASKER CERTIFIED SOLUTION
Avatar of qwaletee
qwaletee

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
hi
the code given by qwalette will work like charm except for the last line

which needs to be changed to either
call memo.import("gif image","c:\report.gif")
or
memo.Import "GIF Image" , "C:\Report.gif"


HTH
Partha
Avatar of rabbani

ASKER

Hi Guys,

Thanks for your response guys. The new memo is opening but the import is not working as i am getting an error at this line.  Can you please help me debug this.

Set memo = workspace.ComposeDocument(db.server, db.filePath,"Memo")  ''The server threw an exception" error at this line.

Code given by Qwalette. I have commented a couple of lines as it was giving an error as "session already initialized"
Appreciate your advise on this.
-------------------------------------------------------------------------------------------------------------------------------------
   Set session = CreateObject("Notes.NotesSession")
   'Call session.Initialize("passwordOptional")
   'Call session.InitializeUsingNotesUserName("name", "passwordOptional")
   UserName = session.UserName
   dbName = Left(UserName, 1) & Right(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
   Set db = session.GETDATABASE("", dbName)

   If db.ISOPEN = True Then
   Else
         db.OPENMAIL
   End If

   Set workspace = CreateObject("Notes.NotesUIWorkspace")
   Set memo = workspace.ComposeDocument(db.server, db.filePath,"Memo")  ''The server threw an exception" error at this line.
   Call memo.gotoField("Body")
   call memo.import("gif image", "C:\Report.gif")
--------------------------------------------------------------------------------------------
Thanks,
Rabbani
Session only needs to be initialized using the "new" COM objects, Lotus.NotesSession.  You used the old ones, Notes.NotesSession, which is fine... they just work differently

Get rid of this absolute horror:
  UserName = session.UserName
  dbName = Left(UserName, 1) & Right(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
  Set db = session.GETDATABASE("", dbName)
Replace it with:
  Set dbDir = session.getDBDirectory()
  Set db = dbDir.openMailDatabase()
Or, since you use the old objectsm this might work better:
  Set db = session.GETDATABASE("", "")
  db.OpenMail

Finally, you never really prperly testto see if you "know" which db you are dealing with, and that it is open.  Replace:
  If db.ISOPEN = True Then
  Else
       db.OPENMAIL
  End If
...with...
  If Not db.IsOpen = True Then
    MsgBox "Error opening mail"
    Exit Sub
  End If
Avatar of rabbani

ASKER

Hi,

Thanks for your suggestion. The following code is working fine except that i am getting an error "The Server threw an exception" at this line Set memo = workspace.ComposeDocument(db.server, db.filePath,"Memo").  
Some times, It is opening a new memo and even importing the Report.gif perfectly, but not always. I appreciate your help in this problem.
---------------------------------------------------------------------------------------------------------------------------------------------


   Set session = CreateObject("Notes.NotesSession")
   Set db = session.GETDATABASE("", "")
   db.OpenMail
   
   If Not db.IsOpen = True Then
       MsgBox "Error opening mail"
      Exit Sub
   End If
      
   Set workspace = CreateObject("Notes.NotesUIWorkspace")
   Set memo = workspace.ComposeDocument(db.server, db.filePath,"Memo")

   On Error Resume Next  'I added this line as it was giving an error at the above line.

   Call memo.gotoField("Body")
   Call memo.import("gif image", "C:\Report.gif")
Sorry, but it works for me every time.

Are you saying that for you, sometimes it works, and sometimes it does not work?
Avatar of rabbani

ASKER


I am sorry, i did not phrase my question properly.  I might be doing some mistake.  I put some message boxes in between the code and it might be the reason.

Is this error "The Server threw an exception" at this line Set memo = workspace.ComposeDocument(db.server, db.filePath,"Memo") due to some settings on my machine or the Notes version.  The exception is always thrown at this line.  
I have taken out those message boxes and my code is now exactly as posted by me in my last comment. I am still getting this error. I am unable to trace the reason for this error.  I appreciate if you can please advise me on the reason for this exception and any settings that i need to make.

Thanks

You may be able to do this using the DDE interface.
Avatar of rabbani

ASKER

Thank you very much Qwaletee,

The problem is exactly as mentioned in the thread mentioned by you. When i maximize the window, it is working perfectly but when the window is mimimized, it is throwing an exception.

I am trying hard to convert the below code to VBScript. Can this be done in VB only?  I appreciate your help.


Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) _
As Long

Public Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Public Const SW_MAXIMIZE = 3

Handle = FindWindow("NOTES", vbNullString)
tmp = ShowWindow(Handle, SW_MAXIMIZE)
VBScript does not support external functions, so far as I know.  Only VB and VBA support that.

However, you can probably accomplish this by just runing the Notes executable (NOTES.EXE).  That will nromally force the Notes window to restore if it is minimized.
Avatar of rabbani

ASKER

Thank you very much Qwaletee for your help. I created a dll of the Widow Opener code and able to call the Maximize window method from VBScript.



Wow!  I thought VBS culd not call DLLs!

Can you post your code?
Avatar of rabbani

ASKER

Hello Qwaletee,

I used the below code (as was given in one of the threads pointed by you) and created a dll. This code works fine with out any changes.

Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) _
As Long

Public Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Public Const SW_MAXIMIZE = 3


Handle = FindWindow("NOTES", vbNullString)
tmp = ShowWindow(Handle, SW_MAXIMIZE)
Hi Qwaltee,

I've used your code to generate a new Lotus Notes memo from MS Access. However, I would like to add text after the memo is inserted. I'm basically using your code but also adding this:

Can you give me an example of code that would allow me to add a SendTo recipient as well as body text?

Thank you kindly!

-youngstar