Autor Thema: Lotus Notes Attachment vs Embedded Object  (Gelesen 6082 mal)

Offline M1N3773

  • Frischling
  • *
  • Beiträge: 1
Lotus Notes Attachment vs Embedded Object
« am: 07.01.08 - 14:10:55 »
Hi

I have a problem I've been struggling with for ages. I have some code for sending an Excel file (from Excel VBA) via Lotus Notes, however, I need the file to be sent as an attachment, but it keeps sending it as an embedded object. I have looked at what feels like hundreds of forums, but I just cannot find an answer!!

Someone tested the code this morning and with the code unmodified, it came through as an attachment!!! So it worked, but I'm still no closer to an answer. At least it looks like it's not a code issue, but more like a version or settings issue. I am unable to find out the version of Lotus Notes that was used to send the test email. I am using version 6.0.2 CF2 on Windows XP.

Do you have any clues about how I could resolve this please? My current vba code below:


Sub SendEmail()
Dim objMailDB As Object
Dim objMailDoc As Object
Dim objSession As Object
Dim objMailRTF As Object
Dim objAttach As Object
DDMMYY = Format(Now, "DDMMYY")
ChDirNet ActiveWorkbook.Path
namefile = ActiveWorkbook.Path & "\WPR_BANG_WC_" & DDMMYY & "_NUD_DISP.xls"

Dim recip(2) As Variant
recip(0) = "clmsra@nn.co.uk"
recip(1) = "m.c@nn.co.uk"

Set objSession = CreateObject("Notes.NotesSession")
Set objMailDB = objSession.GETDATABASE("", "")

If objMailDB.IsOpen = True Then
Else: objMailDB.OPENMAIL
End If

Set objMailDoc = objMailDB.CREATEDOCUMENT
With objMailDoc
.Form = "Memo"
.SendTo = "clmsra@nn.co.uk"
.Subject = "Weekly Performance Reports - " & DDMMYY
.Body = "Please find this week's WPR." & Chr(13) & _
"" & Chr(13) & _
"Thanks"
.SAVEMESSAGEONSEND = True
End With

Set objMailRTF = objMailDoc.CREATERICHTEXTITEM("Attachment")
Set objAttach = objMailRTF.EMBEDOBJECT(1454, "", namefile, "Attachment")
With objMailDoc
.PostedDate = Now()
.SEND 0, recip
End With

Set objMailDB = Nothing
Set objMailDoc = Nothing
Set objSession = Nothing
Set objMailRTF = Nothing
Set objAttach = Nothing
End Sub

Offline flaite

  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 2.966
    • mein del.icio.us
Re: Lotus Notes Attachment vs Embedded Object
« Antwort #1 am: 07.01.08 - 16:14:19 »
Hi,

this is odd.
It may be due to a bug in the specific notes version you are using.
You retrieve information about the version with the NotesVersion property of your NotesSession.
objSession.NotesVersion.

Why didn't you declare your objects with the proper classes?
Dim objMailDB as NotesDatabase
Dim objMailDoc as NotesDcoument
etc.

Its better to use
Code
Set objAttach = objMailRTF.EMBEDOBJECT(NotesRichTextItem.EMBED_ATTACHMENT, "", namefile, "Attachment")
instead of
Code
Set objAttach = objMailRTF.EMBEDOBJECT(1454, "", namefile, "Attachment") ' Magic number. 


regards

Axel
Ich stimm nicht mit allen überein, aber mit vielen und sowieso unterhaltsam -> https://www.youtube.com/channel/UCr9qCdqXLm2SU0BIs6d_68Q

---

Aquí no se respeta ni la ley de la selva.
(Hier respektiert man nicht einmal das Gesetz des Dschungels)

Nicanor Parra, San Fabian, Región del Bio Bio, República de Chile

Offline koehlerbv

  • Moderator
  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 20.460
  • Geschlecht: Männlich
Re: Lotus Notes Attachment vs Embedded Object
« Antwort #2 am: 07.01.08 - 16:32:22 »
Code
Set objAttach = objMailRTF.EMBEDOBJECT(NotesRichTextItem.EMBED_ATTACHMENT, "", namefile, "Attachment")

No, you can't use such a construct: NotesRichTextItem.EmbedObject expects a constant of type integer as the first parameter. You can't replace it with a method of the class NotesRichtextItem.

Nevertheless, I can't see any reason in this code why instead of the desired attachments an embedded object is created. Sorry.

Bernhard

Offline m3

  • Freund des Hauses!
  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 8.102
  • Geschlecht: Männlich
  • Non ex transverso sed deorsum!
    • leyrers online pamphlet
Re: Lotus Notes Attachment vs Embedded Object
« Antwort #3 am: 07.01.08 - 16:45:50 »
Maybe the problem does is not in the code but in the environment?
How do you execute this code? A time-triggered agent on the server, a button in the Notes Client, ...?
HTH
m³ aka. Martin -- leyrers online pamphlet | LEYON - All things Lotus (IBM Collaborations Solutions)

All programs evolve until they can send email.
Except Microsoft Exchange.
    - Memorable Quotes from Alt.Sysadmin.Recovery

"Lotus Notes ist wie ein Badezimmer, geht ohne Kacheln, aber nicht so gut." -- Peter Klett

"If there isn't at least a handful of solutions for any given problem, it isn't IBM"™ - @notessensai

Offline koehlerbv

  • Moderator
  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 20.460
  • Geschlecht: Männlich
Re: Lotus Notes Attachment vs Embedded Object
« Antwort #4 am: 07.01.08 - 16:53:12 »
Martin - this is code inside an Excel sheet ...

Bernhard

Offline m3

  • Freund des Hauses!
  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 8.102
  • Geschlecht: Männlich
  • Non ex transverso sed deorsum!
    • leyrers online pamphlet
Re: Lotus Notes Attachment vs Embedded Object
« Antwort #5 am: 07.01.08 - 16:56:55 »
Right. Thanks. I shouldn't post inbetween two code reviews. ;)
HTH
m³ aka. Martin -- leyrers online pamphlet | LEYON - All things Lotus (IBM Collaborations Solutions)

All programs evolve until they can send email.
Except Microsoft Exchange.
    - Memorable Quotes from Alt.Sysadmin.Recovery

"Lotus Notes ist wie ein Badezimmer, geht ohne Kacheln, aber nicht so gut." -- Peter Klett

"If there isn't at least a handful of solutions for any given problem, it isn't IBM"™ - @notessensai

Offline flaite

  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 2.966
    • mein del.icio.us
Re: Lotus Notes Attachment vs Embedded Object
« Antwort #6 am: 08.01.08 - 09:51:11 »
No, you can't use such a construct: NotesRichTextItem.EmbedObject expects a constant of type integer as the first parameter. You can't replace it with a method of the class NotesRichtextItem.

Nevertheless, I can't see any reason in this code why instead of the desired attachments an embedded object is created. Sorry.

Bernhard
Ok, this is actually the notes Java api, where constants are implemented as final static class members. Anyway, in LotusScript its better to use the EMBED_ATTACHMENT constant instead of the magic number.
See designer help for the <notesRichTextItem>.EmbedObject. 
Ich stimm nicht mit allen überein, aber mit vielen und sowieso unterhaltsam -> https://www.youtube.com/channel/UCr9qCdqXLm2SU0BIs6d_68Q

---

Aquí no se respeta ni la ley de la selva.
(Hier respektiert man nicht einmal das Gesetz des Dschungels)

Nicanor Parra, San Fabian, Región del Bio Bio, República de Chile

 

Impressum Atnotes.de  -  Powered by Syslords Solutions  -  Datenschutz