Avatar billede mmmtm Nybegynder
08. januar 2003 - 22:53 Der er 2 kommentarer og
1 løsning

autoprint af mail - word/ole/com

Kode ønskes til at få en agent på en Domino server til at printe en mail ud via MS Word - OLE/COM, når mailen modtages på serveren.
Avatar billede jogii Nybegynder
10. januar 2003 - 13:26 #1
Det vil nok tage lidt for lang tid at kode det hele forfra for at det kan "betale" sig at gøre det her.


Men jeg fandt noget andet, hvor Mike Woolsey fra SBD skriver følgende:


<table border="1" cellspacing="2" cellpadding="2">
<tr valign="middle" bgcolor="#C0C0C0"><td><a href="/lotus/forum/bptech98.nsf/852562dc0056ebe8052556c20053f942?OpenForm" target="_self"><img border="0" src="/icons/actn124.gif" height="21" width="21" alt=""> Topic</a></td><td><a href="/lotus/forum/bptech98.nsf/852562dc0056ebe985255e47008178f8?OpenForm&amp;ParentUNID=0DF63986B0D35326852565BC005451D2" target="_self"><img border="0" src="/icons/actn131.gif" height="21" width="21" alt=""> Respond</a></td><td><a href="/lotus/forum/bptech98.nsf/723ccd28050f933f852563e1007a1f5e?OpenForm" target="_self"><img border="0" src="/icons/actn107.gif" height="21" width="21" alt=""> ?Bug</a></td><td><a href="/lotus/forum/bptech98.nsf/Mail1?OpenAgent" target="_self"><img border="0" src="/icons/actn001.gif" height="21" width="21" alt=""></a></td></tr>
</table>
<hr><div align="center"><b><font size="1"><br>
</font></b><b><font size="5" color="#000080">Main Topic</font></b><b><font color="#000080"><br>
</font></b></div><b><font size="2" color="#000080">Can Lotus publicize this information to non-Partners?    </font></b>No<br>
<b><font size="2" color="#000080">Subject:</font></b><font size="2" color="#000080">    </font>Notes for NT Server-based Print Agent [Announcement]
<p>Below are two functions which will allow you to operate a limited printing capability from your Notes server. They are debugged on Notes 4.6a servers, <i>but they are not thoroughly tested</i>. Read the additional information before you try to implement anything with these functions.
<p><i>There have been crashes on servers immediately after attempting to implement these agents!</i> However, the crashes have not been directly attributed to these agents, but to other processes on the server interacting with this agent. Do not throw this on a production server and expect the world to be wonderful! Read the caveats, below. Understand the code. Help us all by commenting on what you're running into.
<p>I hope it helps you!
<p>Some additional information when trying to implement these functions in a production environment:
<ul type="disc">
<li>There's a 9-window limit in the Notes client!! The 9-window limit limits this agent's functionality! LotusScript can't close views it opens. So you're limited to a small number of databases to print from. If this is a problem: mail-in databases can help.
<li>The calls are OLE/ActiveX/whatever B. Gates decides to call them in 1998, with all the limitations Microsoft carries with them: that means you can't run lots of them from multiple databases. They do not multithread nicely to the Notes client, and don't expect them to. Run only one agent at a time, per server.
<li>This function will only work where OLE/ActiveX operations are supported: Windows NT ... maybe Win95 (try at your own risk).
<li>While the solution is rather elegant, it cost Solutions By Design a lot of mindpower to hit on the solution. Please give us the credit. If you're using this code, they thought of it, before you did. Leave us the benefit of a comment or two.
<li>If you are running the Notes server as a service: Because of NT problems launching OLE servers from NT services, you may cause some very odd anomalies if you log off while this code is executing. This is not advised. You can run Notes as a service and you can log in if you want, but <i>don't log out</i>. <font color="#000080">There's more: apparently Notes launches minimized when called from OLE. So the Notes client may have to be launched manually, in order to run this script properly. I haven't checked into whether there's an INI setting to force Notes to launch unminimized. See the next point / caveat.</font><font color="#000080"> Okay, even worse, sometimes you get an &quot;OLE Automation Error&quot; back from the script when the server is installed as a service. </font><font color="#ff0000">If you have to run as a service, you should launch the Notes client from the server using the &quot;Shell&quot; command, so that it launches under the same account as the server, who can then access it. That means you must not launch it manually from a login account on the server, unless you can figure out more about OLE security than I have. However, once the Notes client is launched, you can use it with the same caveats expressed in other points. You will have to provide access to the printers by the account Notes is running in (normally, that's SYSTEM). I haven't got this part to work yet. I can get Notes to launch as SYSTEM, but it has not been able to see the printers, even after I've explicitly opened them to SYSTEM. However, I'm also working on a development machine with minimal memory, and this could also be the problem.</font>
<li><font color="#000080">This code uses the Notes client. You must leave the Notes client unminimized in an open window on your server, to run this code. </font><font color="#000080">Minimizing the Notes client results in this error: &quot;</font><font size="2" color="#000080">Notes Error - Specified command is not available from the workspace.</font><font color="#000080">&quot; </font><font color="#ff0000">You can launch the Notes client with a &quot;Shell&quot; call earlier in the agent, and force the Notes client to open in a window. That'll work around this problem.</font>
<li>Do not expect to use the Notes client running on the server, while this agent is running. This code uses UI functions in the Notes client, so windows will be popping up when this code is running.
<li>The code uses the current printer default. Make sure your default printer is where you want things to go.
<li><font color="#000080">Blank out the server field if you get a &quot;not authorized&quot; or &quot;not responding&quot; message. Sometimes, the Notes client on the server can't access its own server, so this is often safer than trying to &quot;loopback&quot; through the network.</font>
<li>Lotus and Solutions By Design hope you will benefit from this collaboration, but neither has the resources to provide this solution to you for free, and then go out &amp; support it. While the specific functionality is implemented using supported functions, only those individual functions are supported! This script comes as-is, and no claim is made as to fitness for use for any particular purpose by Solutions By Design or by Lotus Development Corporation. Hey, it's free, and it cost people to think of it and get it ready for you. Enjoy, but at your own risk.
<li>Lotus Development Corporation also invested a chunk of time to help get this to you. They deserve acknowledgement for their infinite patience. They never lost their temper with me once! Thanks, Lotus/Iris, esp. Carolynn and Betty! You could've creamed me on myriad technicalities, but you didn't, and I appreciate that.</ul>
<br>

<p>This is the &quot;loosest gun&quot;, but also the most direct way to print from the server.
<p><font color="#0000ff">Sub Printit(server As String, dbname As String, view As String, key As String)<br>
</font><font color="#008000">'This print function copyright 1998 and courtesy of Solutions By Design, Vienna, Virginia<br>
'Permission to use is granted only with these comments intact, in their entirety.<br>
'Collaboration is the key to success!</font><font color="#0000ff"><br>
    <br>
    Dim workspace As Variant<br>
    Dim session As Variant<br>
    Dim db As Variant<br>
    Dim doc As Variant<br>
    Dim uidoc As Variant<br>
    Dim unid As String<br>
    <br>
    On Error Goto printerr<br>
    Set workspace = CreateObject(&quot;Notes.NotesUIWorkspace&quot;)<br>
    Call workspace.OpenDatabase(server, dbname, view, key)<br>
    Set uidoc = workspace.EditDocument(False)<br>
    uidoc.Print(0)<br>
    uidoc.Close<br>
    Exit Sub<br>
printerr:<br>
    Print &quot;Error printing document in &quot; + dbname + &quot;, view &quot; + view + &quot;, key &quot; + key + &quot;: &quot; + Error$<br>
    Exit Sub<br>
End Sub</font><br>
<br>
This is a more controlling, better-checking way to print documents by UNID. It's a little more touchy, though.<br>
<br>
<font color="#0000ff">Sub Printit(server As String, dbname As String, view As String, unid As String)<br>
</font><font color="#008000">'This print function copyright 1998 and courtesy of Solutions By Design, Vienna, Virginia<br>
'Permission to use is granted only with these comments intact, in their entirety.<br>
'Collaboration is the key to success!</font><font color="#0000ff"><br>
</font><font color="#0000ff">    Dim workspace As Variant<br>
    Dim session As Variant<br>
    Dim db As Variant<br>
    Dim doc As Variant<br>
    Dim uidoc As Variant<br>
    Dim oper As String<br>
    <br>
    On Error Goto printerr</font><br>
<font color="#800000">    oper = &quot;setting up&quot;</font><font color="#0000ff"><br>
    Set workspace = CreateObject(&quot;Notes.NotesUIWorkspace&quot;)<br>
    Call workspace.OpenDatabase(server, dbname, view)<br>
    <br>
    Set session = CreateObject(&quot;Notes.NotesSession&quot;)<br>
    Set db = session.GetDatabase(server, dbname)<br>
    Set doc = db.GetDocumentByUNID(unid)<br>
    Set uidoc = workspace.EditDocument(False</font><font color="#ff0000">, doc</font><font color="#0000ff">)</font><br>
<font color="#ff0000">    '(sorry, 'doc' was lost during a replication of the design (mentioned as a wishlist in an earlier post....)</font><font color="#ff0000">)</font><font color="#0000ff"><br>
    oper = &quot;printing&quot;<br>
    uidoc.Print(0)<br>
    oper = &quot;closing&quot;<br>
    Call uidoc.Close<br>
    oper = &quot;exiting&quot;<br>
    Exit Sub<br>
printerr:<br>
    Print &quot;Error printing document in &quot; + dbname + &quot;, view &quot; + view + &quot; while &quot; + oper + &quot; unid &quot; + unid + &quot;: &quot; + Error$<br>
</font><font color="#008000">'    Messagebox &quot;Error printing document in &quot; + dbname + &quot;, view &quot; + view + </font><font color="#800000">&quot; while &quot; + oper + &quot;</font><font color="#008000"> unid &quot; + unid + &quot;: &quot; + Error$</font><br>
<font color="#0000ff">    Exit Sub<br>
End Sub</font><div align="center"><b><font color="#ff0000"></font></b></div><br>
<u><font size="2" color="#0000FF">By </font></u><u><font size="2" color="#0000ff">Mike Woolsey</font></u><u><font size="2" color="#0000FF"> </font></u><font size="2" color="#000080"> (</font><u><font size="2" color="#0000FF">Email:</font></u><font size="2"> </font><font size="2">Mike Woolsey/Solutions By Design/US @ SBD @ Notes Net</font><font size="2" color="#000080">)</font><font size="2" color="#000080"> on </font><font size="2" color="#000080">Tue</font><font size="2" color="#000080">, </font><font size="2" color="#000080">Mar</font><font size="2" color="#000080"> </font><font size="2" color="#000080">3</font><font size="2" color="#000080">, </font><font size="2" color="#000080">1998</font><font size="2" color="#000080"> at </font><font size="2" color="#000080">16:20</font><font size="2" color="#000080">.</font><br>
<b><font size="2" color="#000080">Categories:</font></b><font size="2" color="#000080">    </font><font size="2" color="#000080">Design (Applications)</font><b><font size="2" color="#000080"> </font></b><b><font size="2" color="#000080"></font></b><br>
<b><font size="1" color="#000080">Current for:    </font></b><font size="2">90</font><font size="2"> </font><font size="2" color="#000080">days, 'til </font><font size="2">08-06-98</font><b><font size="2"><br>
</font></b><br>
<font size="2" color="#000080">Non-Disclosure and Copyright obligations apply to this material. You may not reproduce or distribute this material without the author's permission.</font>
Avatar billede jogii Nybegynder
10. januar 2003 - 13:30 #2
Nå, det så ikke så pænt ud alligevel. Du kan gemme html-koden i en fil og se den via en browser. Han har nemlig farvet kommentarene meget så det er nemmere at læse.
Løsningen går ud på at lade serveren starte serverens egen Notes-klient op og udskrive derfra. Men den er ikke testet med R5/D6.
//Jörg
Avatar billede mmmtm Nybegynder
25. maj 2003 - 20:50 #3
Hmmm...tør ikke løbe an på noget utestet, samt opstart af klient på serveren...
/takker og lukker.
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Computerworld tilbyder specialiserede kurser i database-management

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester