Link to home
Start Free TrialLog in
Avatar of hollyjon
hollyjonFlag for United States of America

asked on

Change order or position of Lotus Note attachments using VBA

I'm using the following code to mail reports as attachments that have been printed as .pdf files. The reports are printed from the same database. This could be relevant if changing the name of the files or the order in which they are printed would help resolve my issue.

The problem is that the manager wants the attachments to appear in a specified order. How does Lotus Notes determine what order to display the attachments?

Lotus Notes consistently uses the same order.  I have tried changing:
1. The order of the reports in the Attachment variable (seems like the most obvious)
2. The alphanumeric order of the name of the reports
3. The creation date of the reports
4. The modified date of the reports
5. The size of the reports
6. The length of the name of the reports

What attribute does Lotus Notes use to determine the order of the attachments? It must be using some logic, as the results are always the same. But I can't tell what attribute of the file Lotus Notes is using to determine the order.
Help!


CODE USED:
'Start a session to notes
   Set Session = CreateObject("Notes.NotesSession")
   'Get the sessions username and then calculate the mail file name
   'You may or may not need this as for MailDBname with some systems you
   'can pass an empty string
   
   
   MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
   'Open the mail database in notes
   Set Maildb = Session.GETDATABASE("", MailDbName)
   If Maildb.IsOpen = True Then
        'Already open for mail
   Else
        Maildb.OPENMAIL
   End If
   
   'Set up the new mail document
   Set MailDoc = Maildb.CREATEDOCUMENT
   With MailDoc
        .Form = "Memo"
        .Subject = Subject
        .Body = BodyText
        .SAVEMESSAGEONSEND = SaveIt
       
        'Access 2000, Access XP
        'Allows for multiple SendTo,CopyTo,BlindCopy,Attachment
        .SendTo = Split(SendTo, ",")
        .CopyTo = Split(CC, ",")
        .BlindCopyTo = Split(BCC, ",")
        'Set up the embedded object and attachment and attach it
           
        StartAttach = True
        aryAttachment = Split(Attachment, "|")
        For intAttach = LBound(aryAttachment) To UBound(aryAttachment)
            intGotAttachment = intGotAttachment + 1
            Set AttachME = .createrichtextitem("Attachment" & CStr(intAttach))
            Set EmbedObj = AttachME.embedObject(1454, "", aryAttachment(intAttach), "Attachment" & CStr(intAttach))
        Next intAttach
        StartAttach = False

   'Send the document
        If intGotAttachment > 0 Then
            .PostedDate = Now() 'Gets the mail to appear in the sent items folder
            .Send False
            SendNotesMail = "Sent"
        Else
            SendNotesMail = "Not Sent"
        End If
   End With
   
Clean_Up:
   'Clean Up
   Set Maildb = Nothing
   Set MailDoc = Nothing
   Set AttachME = Nothing
   Set Session = Nothing
   Set EmbedObj = Nothing
   
   Exit Function
   
Notes_Error:
    If StartAttach = True Then
        intGotAttachment = intGotAttachment - 1
        Resume Next
    Else
        MsgBox "Error constructing Lotus Notes message"
        Resume 'Clean_Up
    End If
   
End Function
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

hollyjon,

Some links:

http://mail-archives.apache.org/mod_mbox/james-server-user/200505.mbox/%3C20050512173830.70639.qmail@web41907.mail.yahoo.com%3E

This pdf claims that the attachment order depends on the order that you select the files:
http://www.redbooks.ibm.com/redbooks/pdfs/sg245941.pdf

This mentions the attachment order in regard to the "Rule Order"
http://ftp.support.veritas.com/pub/support/products/Exchange_Mailbox_Archiving_Unit/282074.pdf

If none of these help, perhaps you should close this out and re-post it to the Lotus Topic Area:
https://www.experts-exchange.com/Applications/Email/Lotus_Notes_Domino/


Good luck
Avatar of hollyjon

ASKER


The redbooks reference concerns the order of html file attachments in a fax. Unfortunately, the reason I'm asking is because the attachments do not "appear in the ... in the order they were added"

The veritats.com pertains to Exchange not Domino.

Unfortunately I need to use Lotus Notes and was hoping someone else might have had a similar need to control the order.

Interesting...

You say:
<Lotus Notes consistently uses the same order>
What is this order?

What I mean is, if you attached a Word, Excel, Bitmap file, would they always be in the same order.
(Word, Excel, Bitmap)
Or is it alway some other order like:
(Excel, Bitmap, Word)
Or is it random?

Suppose you attached a different set of Word, Excel, and Bitmap... Would it always be the same order as the first three?
Although that's an interesting question, it's not one that I have time to explore. "I'm using the following code to mail reports as attachments that have been printed as .pdf files." The problem that I need to solve is what order/logic is being applied when several files of the same type (and specifically .pdf files) are attached? How do I control that scenario?

As to the question of "What is the order?", that's an excellent question, but one that has me stumped. My assumption was that the attachments would appear in the same order that they are added to the string variable "Attachment". But that is not the order in which they appear.

Or maybe they do.... I'm going back and look at my strings again, perhaps I'm not adding them in the order that I think I am.  

"I'll be back."



       
All right. Did some analysis on a sample and here's the results. The problem is that the "Order in email" needs to be the same as "Order added".  The "Alpha order" is close to the "Order added", because I chose to do that throught the code that creates the attachment string. I'm including it so that it is clear that the "Alpha order" is not influencing the "Order in email". The "Set" number references an email so all the files in set 1 are in the first email, etc.

Set|order added|Order in email|Alpha order|Size (kb)      |File
1      1      1      2      16      Rpt1b.pdf
1      2      4      1      15      Rpt1a.pdf
1      3      2      3      12      Rpt1c.pdf
1      4      3      4      12      Rpt1d.pdf
2      1      3      2      13      Rpt2b.pdf
2      2      4      1      61      Rpt2a.pdf
2      3      2      3      611      Rpt2c.pdf
2      4      1      4      12      Rpt2d.pdf
3      1      10      2      17      Rpt3b.pdf
3      2      11      1      37      Rpt3a.pdf
3      3      7      3      79      Rpt3c.pdf
3      4      5      4      20      Rpt3d.pdf
3      5      8      5      70      Rpt3e.pdf
3      6      6      6      95      Rpt3f.pdf
3      7      3      7      57      Rpt3g.pdf
3      8      2      8      13      Rpt3h.pdf
3      9      1      9      64      Rpt3i.pdf
3      10      4      10      51      Rpt3j.pdf
3      11      9      11      17      Rpt3k.pdf
Did any of the links provide any info?
No, but I have a partial solution.  We noticed that some were sent using the internal address and some with the external address. If the internal address is used then we retain the correct order (and the nice formatting).  The external address will result in some still undetermined order. So, if an internal address is available, those emails will contain the attachment in the correct order.

However, for a mass mailing, I only have access to a list of external addresses. So, I would still like to hear if someone has a solution for controlling the order of attachments using an external address.




ASKER CERTIFIED SOLUTION
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

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
Well, at least you gave it some attention.  And you're advice to try the question in the Lotus Notes section is probably the best advice. Thanks.  

For anyone checking out this question, the main answer is to use internal addresses if at all possible.
hollyjon,

Thanks,
But you did not have to Accept my posts if they did not solve your problem.

If you want to change this contact:
https://www.experts-exchange.com/Community_Support/CleanUp/

I'll leave it up to you.
:)

Jeff