[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Lotus Notes ver 6.0.1 mail attachment problem with MS Access/VB code

Posted on 2005-05-17
29
Medium Priority
?
2,253 Views
Last Modified: 2013-12-18
We have a problem attaching html file (ex. a.htm) to emails that we create using a VB code. We first create the HTML file as a report and we use below VB code to connect Lotus and send the email. Our previous version was for Lotus 5.0.9 and it was working perfectly. Now the lotus clients are upgraded and new code doesn't accept attachments to the emails.

We tried to solve the problem for two months but couldn't.

The error message is 'Object doesn't support this property or method.'.

Here is the mailing part of the code:
----------------------------
Private Function funSendOne(MyRec As String, myBody As String, myHTML As String, MyAttachFile As String, Optional SaveIt As Boolean = False)
Dim MailDB As Object ' The mail database
Dim UserName As String 'The current users notes name
Dim MailDbName As String 'the current users notes mail database name
Dim MailDoc As Object ' The mail document itself
Dim Session As Object 'The notes session
Dim EmbedObj As Object   'the embedded object(attachment)
Dim Server As String
Dim AttachME As Object

On Error GoTo Err_funSendOne
 
Open MyAttachFile For Output As #3
   Print #3, myHTML
Close #3
   
  Set Session = CreateObject("Notes.NotesSession")
  Server = "serverx"
  MailDbName = "mail60/msg.nfs"
  UserName = "abc@mailserver.com"
 
  Set MailDB = Session.GetDatabase(Server, MailDbName)
  MailDB.OPENMAIL
  Set MailDoc = MailDB.CreateDocument
 
   If (MyAttachFile <> "") Then
       Set AttachME = MailDoc.CreateRichTextItem("Attachment")                                    'system gives error on this line!
       Set EmbedObj = AttachME.EmbedObject(1454, "", MyAttachFile, "Attachment")
        'MailDoc.CreateRichTextItem ("MyAttachFile")
   End If
   
    MailDoc.Form = "Memo"
    MailDoc.subject = CStr(TxtSubject)
    MailDoc.myBody = Replace(myBody, "<BR>", vbLf, 1)
    MailDoc.SaveMessageOnSend = SaveIt
    MailDoc.Save False, False
    MailDoc.PostedDate = Now()
    MailDoc.Send 0, MyRec
 
 
   Set MailDB = Nothing
   Set MailDoc = Nothing
   Set AttachME = Nothing
   Set ws = Nothing
   Set Session = Nothing
   Set EmbedObj = Nothing
   
  funSendOne = True
  Exit Function

Err_funSendOne:
  priError = Err.Description
  funSendOne = False
MsgBox priError
End Function
----------------------------

Thnx.
0
Comment
Question by:ssusuz
  • 11
  • 9
  • 9
29 Comments
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 14020353
First question: if you debug your code, where does it stop, on what line? Or could you add an Erl somewhere, like
      priError = Err.Description & " on line " & Erl

The Help Db says not to use OpenMail, but to use OpenMailDatabase in NotesDbDirectory, like
    Set dbDir= Session.GetDbDirectory
    Set MailDb= dbDir.OpenMailDatabase
   
If you know the name of the mail database, you could just use
    maildb.Open "",""
0
 

Author Comment

by:ssusuz
ID: 14026904
Thanks for quick reply sjef_bosman.

If we debug it stops at the following line and the error message is Type Mismatch:

    Set AttachME = MailDoc.CreateRichTextItem("Attachment")                                    'system gives error on this line!

If we try to use OpenMailDatabase then dbDir doesn't get any value. It doesn't connect.

We used maildb.Open command but it also returns no value. No connection.



0
 
LVL 31

Expert Comment

by:qwaletee
ID: 14027312
I don't believe this code, as you gave it, ever worked.


  Set MailDB = Session.GetDatabase(Server, MailDbName)
  MailDB.OPENMAIL
These two lines in sequence would cause an error, because after the first, the database woudl already be open, so the second would be an attempt to open an object that was already open.


  MailDbName = "mail60/msg.nfs"
I have a hard time believing t hat you have a file with an extension of .nfs
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:ssusuz
ID: 14028019
gwaletee thanks.

If we don't use MailDB.OPEN after
Set MailDB = Session.GetDatabase(Server, MailDbName)
then we cannot even send mail. Currently we can send emails if we ignore attachment problem.

The file extension is .nsf there was a mistake when during paste.
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 14030549
I just tried your code under R5, using VBA in WOrd (should be same as in ACcess), and OPENMAIL threw the error as expected.  So there's something odd about even your R5 setup.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 14034459
ssusuz,

You should test the return value of most of the Notes methods.

> Set MailDoc = MailDB.CreateDocument
    If MailDoc Is Nothing Then
        MsgBox "MailDoc is Nothing!"
        Exit Sub
    End If

The Type Mismatch will happen when MailDoc isn't a NotesDocument. Which might mean that you don't have sufficient rights to create documents.

But, first, correct the code tas we suggested earlier
.
Sjef
0
 

Author Comment

by:ssusuz
ID: 14034577
This doesn't work really. There is something unusual. How can I put the HTML page in the Body of message instead of creating as an attachment? I tried and message sent successfully, but I see the unformatted html code on the body. This can help...
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 14034610
Not to discourage you too much, but sending HTML-mail from Domino isn't possible.

You can set text as passthru-HTML. Create a richtext-style, and set the PassThruHTML property. Then use NotesRichTextItem.AppendText to add text and NotesRichTextItem.AddNewline to add new lines.
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 14041484
Sjef, don't be so negative!

DavyNonkel published a way to call the Notes native API to send HTML messages.  It should be easily adaptable to VB calls to DLLs.  You can find it here on EE.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 14043887
Is it possible? Shame on me! I didn't know that. I always try to be very careful with "isn't possible", for there are loopholes and trapdoors everywhere in Notes, to go beyond what's supposed to be possible in Notes. I'm sorry ssusuz, apparently it is possible to send HTML mails, albeit rather low-level.
0
 

Author Comment

by:ssusuz
ID: 14044029
But I couldn't find DavyNonkel's article. :(
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 14044106
I think Qwaletee referred to http:Q_21285225.html "Sending Rich Text/HTML Mails to Lotus Notes R6x recipients"

I also found this link for you: http:Q_20961515.html "Send Formated html in lotus?"

There's no question I can find with the word "DavyNonkel" in it.
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 14047068
First link is off topic.  Second link contains Ranjeet's link to Davy's code on OpenNTF, though he origially developed it in response to an EE question

This link will take you directly to Ranjeet's comment.  http:Q_20961515.html#10876390 "Send Formated html in lotus?"
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 14047088
Oh, and his name on EE is nBlade, not DavyNonkey.  Mixed it up with a handle he uses elsewhere.
0
 

Author Comment

by:ssusuz
ID: 14060980
I checked the link and this has a limitation 32K. I need really more space to put all information.
By the way the following doesn't give any error message and works fine. It can create the document.

    Set MailDoc = MailDB.CreateDocument
    If MailDoc Is Nothing Then
        MsgBox "MailDoc is Nothing!"
        Exit Sub
    End If

0
 
LVL 31

Expert Comment

by:qwaletee
ID: 14062382
You are mixing up two different issues, let's cover one at a time.  You wanted to do an attchment.  Now you've changed it to wanting to do HTML.  If you want the answer to an HTML question, aks an HTML question.

0
 

Author Comment

by:ssusuz
ID: 14066299
qwaletee,
HTML was just an idea because the problem was urgent. Now I understood that it doesn't cover all requirements.
My first question is still valid. I am trying to attach a file to Lotus mail.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 14066363
It may be a totally different error. Are you running R6.x now? Did you do some (!) design changes with an R6-Designer client? Then it may be that the compiled code is no longer compatible.

In the R6-Designer, user Tools/Recompile All LotusScript. Then try again.
0
 

Author Comment

by:ssusuz
ID: 14066492
sjef,
We are running R 6.0.1 now. Our code is on MS Access. Sorry I could't understand Recompile part. We don't have any Script on Lotus.
By the way good point there are probably designs on our installation. I will check what is different exactly.
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 14074704
Just for fun, could you download an updated client -- 6.0.4 or 6.5.4 -- and see how it runs there?

There seems to be an inconsistency in your reporting.  initially, you reported the error as object does not support this property or method, then later as a type mismatch.  Why the disparity?

Also, try replacing these lines...
  Set MailDB = Session.GetDatabase(Server, MailDbName)
  MailDB.OPENMAIL
  Set MailDoc = MailDB.CreateDocument
   If (MyAttachFile <> "") Then
       Set AttachME = MailDoc.CreateRichTextItem("Attachment")                                    'system gives error on this line!
       Set EmbedObj = AttachME.EmbedObject(1454, "", MyAttachFile, "Attachment")

...with...
  Set MailDB = Session.GetDatabase(Server, MailDbName)
  If Not MailDB.IsOpen Then
    MsgBox "Did not open directly, trying .Open"
    MailDB.Open "" , ""
  End If
  If Not MailDB.IsOpen Then
    MsgBox "Did not open via .Open, trying .OpenMail"
    MailDB.OPENMAIL
  End If
  If Not MailDB.IsOpen Then
    MsgBox "Did not open via .OpenMail, giving up!!!!!!!!!!!!!!!!!!!!!!!!!!!"
    Exit Function
  End If
  Set MailDoc = MailDB.CreateDocument
  If MailDoc Is Nothing Then
    MsgBox "Could not create document, gving up!!!!"
    Exit Function
  End If

   If (MyAttachFile <> "") Then
        MsgBox "Creating container for attachment"
       Set AttachME = MailDoc.CreateRichTextItem("Attachment")                                    'system gives error on this line!
        MsgBox "Attaching file to container"
       Set EmbedObj = AttachME.EmbedObject(1454, "", MyAttachFile, "Attachment")
        MsgBox "File attached, continuing with message creation"

0
 

Author Comment

by:ssusuz
ID: 14076458
Thanks qwaletee,

Good idea, but unfortunately we are limited to use 6.0.1.

We tried the coding, but still have problem with the attachment. I included debug results below.

 Set MailDB = Session.GetDatabase(Server, MailDbName)
  If Not MailDB.IsOpen Then
    MsgBox "Did not open directly, trying .Open"                         ‘Gives this message
    MailDB.Open "" , ""                        ‘Couldn’t open
  End If
  If Not MailDB.IsOpen Then
    MsgBox "Did not open via .Open, trying .OpenMail"  ‘Gives this message
    MailDB.OPENMAIL                              ‘MailDB Opens
  End If
  If Not MailDB.IsOpen Then                        ‘Passed that if clause
    MsgBox "Did not open via .OpenMail, giving up!!!!!!!!!!!!!!!!!!!!!!!!!!!"
    Exit Function
  End If
  Set MailDoc = MailDB.CreateDocument                                         ‘MailDoc created, no message
  If MailDoc Is Nothing Then                                      ‘Passed that if clause
    MsgBox "Could not create document, gving up!!!!"
    Exit Function
  End If

   If (MyAttachFile <> "") Then
        MsgBox "Creating container for attachment"
       Set AttachME = MailDoc.CreateRichTextItem("Attachment")      ‘Still gives type mismatch error and breaks
        MsgBox "Attaching file to container"
       Set EmbedObj = AttachME.EmbedObject(1454, "", MyAttachFile, "Attachment")
        MsgBox "File attached, continuing with message creation"
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 14076614
I think we're not getting nearer a solution.

Can you create a very small Access database, with the mail plus attachment functionality, can you test it and then send it to anyone asking for it? You can find my mail address in my EE-profile.

One idea though: did you remove the whole R5-related programs tree? Or do you have a dual R5/R6 system?
0
 
LVL 31

Assisted Solution

by:qwaletee
qwaletee earned 150 total points
ID: 14081478
I know you are limited to the version in use... but try setting up a test box just to try it out.  Nad as I said before, definitely something hinky here, because I get errors if I try .Open and .OpenMail, because the database is already open for me at that point.  That's in both R5 and R6.

Just wondering if there could be a bug in teh OLE automation interface for 6.0.1 specifically.

ou can also try using teh COM classes instead of the OLE automation classes.  Use Lotus.NotesSession insetad of Nots.NotesSession, followed immediately by Session.Initialize (may prompt for password if you don't have Windows single sign on or ID file password sharing in place).
0
 

Author Comment

by:ssusuz
ID: 14085604
Hi Sjef,
I couldn't find your email address in EE-profile. I can send you our Access file.

We have removed all R5 files before installation of R6.

0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 14085703
The address is there, at the bottom, but in a spam-friendly form, with the word at instead of the at-sign.
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 14087075
sjef_bosman,

> spam-friendly
Leaving the @ in would be spam friendly.  I think you are downright spam-unfriendly, Sjef.

- qwaletee
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 14087881
LOL True. May I change it in "a-user-who-doesn't-like-spam-friendly" ?
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 14087974
ssusuz,

Some "manual" would be nice, so I don't have to plod through all your code and/or forms. I hope everything will work in this version of Access (2000). The autoexec already gave some trouble.

Sjef
0
 
LVL 46

Accepted Solution

by:
Sjef Bosman earned 1350 total points
ID: 14090074
Done the plodding... :|

There's one line missing in your code:

  Set Session = CreateObject("Notes.NotesSession")
  Server = "xxxx"
  MailDbName = "mail/xxxx.nsf"    'user information
  UserName = "xxxx@xxxx.com"
 
  Set MailDB = Session.GetDatabase("", "") ' - added -
 
  MailDB.OPENMAIL
  Set MailDoc = MailDB.CreateDocument

Must have been there, if it used to work. Why it disappeared, that's yours to find out. Time for SCCS or Visual SourceSafe...
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

830 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