Prompt to Print on Send

S

Stampie

A user operates a Windows XP, Office 2003 computer.

They have asked if it is possible to have a prompt to print upon sending an
email. I've never heard anything like this that sounds possible, but I can't
rule it out completely. Any ideas?

Please point me in the right direction if I'm in the wrong newsgroup.

Thanks.
 
M

Michael Bauer [MVP - Outlook]

That could be done with a few lines of VBA code. This sample prints received
emails and can easily be adpated:
http://www.vboffice.net/sample.html?mnu=2&pub=6&smp=48&cmd=showitem&lang=en

Replace:

Private Sub Items_ItemAdd(ByVal Item As Object)

by (in one row):

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)

And replace:

If Mail.UnRead Then

by:

if MsgBox("Print?",vbYesNo or vbQuestion)=vbYes Then

--
Best regards
Michael Bauer - MVP Outlook
Use Outlook Categories? This is Your Tool:
<http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>

Am Mon, 10 Mar 2008 09:57:01 -0700 schrieb Stampie:
 
S

Stampie

Where does the *.OTM file need to be in order for it to work?

I've tried just saving the script then restarting Outlook and sending a test
without success.

Never known how to use VB so can you explain in simple terms please?

Thanks.
 
M

Michael Bauer [MVP - Outlook]

The file is being created and saved automatically by Outlook; you can find
the file then in:

C:\Documents and Settings\[user]\Application Data\Microsoft\Outlook

In Outlook click on Tools/Macro/Security and set it to execute unsigned
code, i.e. medium or low.

Then open the VBA environment (alt+f11), the project explorer (ctrl+r), find
and double click "ThisOutlookSession", and then copy the code into that
module.

Edit the code as suggested, click Save, and restart Outlook.

--
Best regards
Michael Bauer - MVP Outlook
Use Outlook Categories? This is Your Tool:
<http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>

Am Tue, 11 Mar 2008 02:53:02 -0700 schrieb Stampie:
 
S

Stampie

Thats great! It worked!

Just a couple of problems though, after clicking on send, it appears as
though Outlook hangs, but the print prompt window is sitting behind the email
I tried sending. I can minimize the message to get to the windowbut i'd
prefer if it could be brought to the front. Can it be edited to do that?

Also after the email printed, instead of having all the headings at the top
of the page (To, Cc, Bcc, Subject, etc) they were replaced with the following
lines of text...

{\rtf1\ansi\ansicpg1252\deff0\deflang2057{\f0\fswiss\fcharset0 Arial;}}
{\colortbl ;\red0\green0\blue0;} {\*\generator Riched20
5.50.99.2050;}\viewkind4\uc1\pard\fi-1800\li1800\tx1800\cf1\b\f0\fs20
<sendername>\par To:tab\b0 <recipientname>\par \b Subject:\tab\b0
<subjectname>\par }

A colleague performed the exact same steps without any problems, although he
was using Office 2007, I on the other hand, have Office 2003 SP3.

Is it another bug in SP3 that may be causing this or have I got the wrong
code for Office 2003?

Thanks for the fix though!



:

The file is being created and saved automatically by Outlook; you can find
the file then in:

C:\Documents and Settings\[user]\Application Data\Microsoft\Outlook

In Outlook click on Tools/Macro/Security and set it to execute unsigned
code, i.e. medium or low.

Then open the VBA environment (alt+f11), the project explorer (ctrl+r), find
and double click "ThisOutlookSession", and then copy the code into that
module.

Edit the code as suggested, click Save, and restart Outlook.

--
Best regards
Michael Bauer - MVP Outlook
Use Outlook Categories? This is Your Tool:
<http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>

Am Tue, 11 Mar 2008 02:53:02 -0700 schrieb Stampie:
Where does the *.OTM file need to be in order for it to work?

I've tried just saving the script then restarting Outlook and sending a test
without success.

Never known how to use VB so can you explain in simple terms please?

Thanks.
 
M

Michael Bauer [MVP - Outlook]

1#: That happens if you use Word as email editor. Easiest approach is indeed
to minimize the Inspector. You can do that by code by calling
Item.GetInspector.WindowState=vbMinimized

#2: I don't know the reason for that. Do you sent your emails RTF formatted?

You might test if this helps:

If not Item.GetInspector.Wordeditor is Nothing Then
Item.GetInspector.WordEditor.PrintOut
Else
Item.PrintOut
Endif

--
Best regards
Michael Bauer - MVP Outlook
Use Outlook Categories? This is Your Tool:
<http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>

Am Tue, 11 Mar 2008 04:47:02 -0700 schrieb Stampie:
Thats great! It worked!

Just a couple of problems though, after clicking on send, it appears as
though Outlook hangs, but the print prompt window is sitting behind the email
I tried sending. I can minimize the message to get to the windowbut i'd
prefer if it could be brought to the front. Can it be edited to do that?

Also after the email printed, instead of having all the headings at the top
of the page (To, Cc, Bcc, Subject, etc) they were replaced with the following
lines of text...

{\rtf1\ansi\ansicpg1252\deff0\deflang2057{\f0\fswiss\fcharset0 Arial;}}
{\colortbl ;\red0\green0\blue0;} {\*\generator Riched20
5.50.99.2050;}\viewkind4\uc1\pard\fi-1800\li1800\tx1800\cf1\b\f0\fs20
<sendername>\par To:tab\b0 <recipientname>\par \b Subject:\tab\b0
<subjectname>\par }

A colleague performed the exact same steps without any problems, although he
was using Office 2007, I on the other hand, have Office 2003 SP3.

Is it another bug in SP3 that may be causing this or have I got the wrong
code for Office 2003?

Thanks for the fix though!



:

The file is being created and saved automatically by Outlook; you can find
the file then in:

C:\Documents and Settings\[user]\Application Data\Microsoft\Outlook

In Outlook click on Tools/Macro/Security and set it to execute unsigned
code, i.e. medium or low.

Then open the VBA environment (alt+f11), the project explorer (ctrl+r), find
and double click "ThisOutlookSession", and then copy the code into that
module.

Edit the code as suggested, click Save, and restart Outlook.
 
S

Stampie

Do I just add the codes below onto the bottom of the code you gave me before
or do I create a new one?



Michael Bauer said:
1#: That happens if you use Word as email editor. Easiest approach is indeed
to minimize the Inspector. You can do that by code by calling
Item.GetInspector.WindowState=vbMinimized

#2: I don't know the reason for that. Do you sent your emails RTF formatted?

You might test if this helps:

If not Item.GetInspector.Wordeditor is Nothing Then
Item.GetInspector.WordEditor.PrintOut
Else
Item.PrintOut
Endif

--
Best regards
Michael Bauer - MVP Outlook
Use Outlook Categories? This is Your Tool:
<http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>

Am Tue, 11 Mar 2008 04:47:02 -0700 schrieb Stampie:
Thats great! It worked!

Just a couple of problems though, after clicking on send, it appears as
though Outlook hangs, but the print prompt window is sitting behind the email
I tried sending. I can minimize the message to get to the windowbut i'd
prefer if it could be brought to the front. Can it be edited to do that?

Also after the email printed, instead of having all the headings at the top
of the page (To, Cc, Bcc, Subject, etc) they were replaced with the following
lines of text...

{\rtf1\ansi\ansicpg1252\deff0\deflang2057{\f0\fswiss\fcharset0 Arial;}}
{\colortbl ;\red0\green0\blue0;} {\*\generator Riched20
5.50.99.2050;}\viewkind4\uc1\pard\fi-1800\li1800\tx1800\cf1\b\f0\fs20
<sendername>\par To:tab\b0 <recipientname>\par \b Subject:\tab\b0
<subjectname>\par }

A colleague performed the exact same steps without any problems, although he
was using Office 2007, I on the other hand, have Office 2003 SP3.

Is it another bug in SP3 that may be causing this or have I got the wrong
code for Office 2003?

Thanks for the fix though!



:

The file is being created and saved automatically by Outlook; you can find
the file then in:

C:\Documents and Settings\[user]\Application Data\Microsoft\Outlook

In Outlook click on Tools/Macro/Security and set it to execute unsigned
code, i.e. medium or low.

Then open the VBA environment (alt+f11), the project explorer (ctrl+r), find
and double click "ThisOutlookSession", and then copy the code into that
module.

Edit the code as suggested, click Save, and restart Outlook.
Am Tue, 11 Mar 2008 02:53:02 -0700 schrieb Stampie:

Where does the *.OTM file need to be in order for it to work?

I've tried just saving the script then restarting Outlook and sending a
test
without success.

Never known how to use VB so can you explain in simple terms please?

Thanks.



:

That could be done with a few lines of VBA code. This sample prints
received
emails and can easily be adpated:

http://www.vboffice.net/sample.html?mnu=2&pub=6&smp=48&cmd=showitem&lang=en

Replace:

Private Sub Items_ItemAdd(ByVal Item As Object)

by (in one row):

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As
Boolean)

And replace:

If Mail.UnRead Then

by:

if MsgBox("Print?",vbYesNo or vbQuestion)=vbYes Then
Am Mon, 10 Mar 2008 09:57:01 -0700 schrieb Stampie:

A user operates a Windows XP, Office 2003 computer.

They have asked if it is possible to have a prompt to print upon sending
an
email. I've never heard anything like this that sounds possible, but I
can't
rule it out completely. Any ideas?

Please point me in the right direction if I'm in the wrong newsgroup.

Thanks.
 
M

Michael Bauer [MVP - Outlook]

Replace the existing ...Printout line by the new lines, please.

--
Best regards
Michael Bauer - MVP Outlook
Use Outlook Categories? This is Your Tool:
<http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>

Am Wed, 12 Mar 2008 02:06:02 -0700 schrieb Stampie:
Do I just add the codes below onto the bottom of the code you gave me before
or do I create a new one?



Michael Bauer said:
1#: That happens if you use Word as email editor. Easiest approach is indeed
to minimize the Inspector. You can do that by code by calling
Item.GetInspector.WindowState=vbMinimized

#2: I don't know the reason for that. Do you sent your emails RTF formatted?

You might test if this helps:

If not Item.GetInspector.Wordeditor is Nothing Then
Item.GetInspector.WordEditor.PrintOut
Else
Item.PrintOut
Endif
Am Tue, 11 Mar 2008 04:47:02 -0700 schrieb Stampie:
Thats great! It worked!

Just a couple of problems though, after clicking on send, it appears as
though Outlook hangs, but the print prompt window is sitting behind the email
I tried sending. I can minimize the message to get to the windowbut i'd
prefer if it could be brought to the front. Can it be edited to do that?

Also after the email printed, instead of having all the headings at the top
of the page (To, Cc, Bcc, Subject, etc) they were replaced with the following
lines of text...

{\rtf1\ansi\ansicpg1252\deff0\deflang2057{\f0\fswiss\fcharset0 Arial;}}
{\colortbl ;\red0\green0\blue0;} {\*\generator Riched20
5.50.99.2050;}\viewkind4\uc1\pard\fi-1800\li1800\tx1800\cf1\b\f0\fs20
<sendername>\par To:tab\b0 <recipientname>\par \b Subject:\tab\b0
<subjectname>\par }

A colleague performed the exact same steps without any problems,
although
he
was using Office 2007, I on the other hand, have Office 2003 SP3.

Is it another bug in SP3 that may be causing this or have I got the wrong
code for Office 2003?

Thanks for the fix though!



:


The file is being created and saved automatically by Outlook; you can find
the file then in:

C:\Documents and Settings\[user]\Application Data\Microsoft\Outlook

In Outlook click on Tools/Macro/Security and set it to execute unsigned
code, i.e. medium or low.

Then open the VBA environment (alt+f11), the project explorer (ctrl+r), find
and double click "ThisOutlookSession", and then copy the code into that
module.

Edit the code as suggested, click Save, and restart Outlook.
Am Tue, 11 Mar 2008 02:53:02 -0700 schrieb Stampie:

Where does the *.OTM file need to be in order for it to work?

I've tried just saving the script then restarting Outlook and sending a
test
without success.

Never known how to use VB so can you explain in simple terms please?

Thanks.



:

That could be done with a few lines of VBA code. This sample prints
received
emails and can easily be adpated:
http://www.vboffice.net/sample.html?mnu=2&pub=6&smp=48&cmd=showitem&lang=en
Replace:

Private Sub Items_ItemAdd(ByVal Item As Object)

by (in one row):

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As
Boolean)

And replace:

If Mail.UnRead Then

by:

if MsgBox("Print?",vbYesNo or vbQuestion)=vbYes Then
Am Mon, 10 Mar 2008 09:57:01 -0700 schrieb Stampie:

A user operates a Windows XP, Office 2003 computer.

They have asked if it is possible to have a prompt to print upon sending
an
email. I've never heard anything like this that sounds possible, but I
can't
rule it out completely. Any ideas?

Please point me in the right direction if I'm in the wrong newsgroup.

Thanks.
 
S

Stampie

Sorry i'm really not very good at this at all :(

Below is the currently edited code (without the new lines in) can you show
me where to place he new lines as i've tried the lines Mail.PrintOut and
PrintNewItem Item without success.

_____________________________________________
Private WithEvents Items As Outlook.Items
_____________________________________________
Private Sub Application_Startup()
Dim Ns As Outlook.NameSpace

Set Ns = Application.GetNamespace("MAPI")
Set Items = Ns.GetDefaultFolder(olFolderInbox).Items
End Sub
_____________________________________________
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
If TypeOf Item Is Outlook.MailItem Then
PrintNewItem Item
End If
End Sub
_____________________________________________
Private Sub PrintNewItem(Mail As Outlook.MailItem)
On Error Resume Next

If MsgBox("Print?", vbYesNo Or vbQuestion) = vbYes Then
Mail.PrintOut
End If
End Sub
____________________________________________
 
M

Michael Bauer [MVP - Outlook]

Sure, replace this
Mail.PrintOut

by this:

If not Mail.GetInspector.Wordeditor is Nothing Then
Mail.GetInspector.WordEditor.PrintOut
Else
Mail.PrintOut
Endif

(There was a typo, it doesn't read 'item' but 'mail').

--
Best regards
Michael Bauer - MVP Outlook
Use Outlook Categories? This is Your Tool:
<http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>

Am Thu, 13 Mar 2008 03:17:01 -0700 schrieb Stampie:
Sorry i'm really not very good at this at all :(

Below is the currently edited code (without the new lines in) can you show
me where to place he new lines as i've tried the lines Mail.PrintOut and
PrintNewItem Item without success.

_____________________________________________
Private WithEvents Items As Outlook.Items
_____________________________________________
Private Sub Application_Startup()
Dim Ns As Outlook.NameSpace

Set Ns = Application.GetNamespace("MAPI")
Set Items = Ns.GetDefaultFolder(olFolderInbox).Items
End Sub
_____________________________________________
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
If TypeOf Item Is Outlook.MailItem Then
PrintNewItem Item
End If
End Sub
_____________________________________________
Private Sub PrintNewItem(Mail As Outlook.MailItem)
On Error Resume Next

If MsgBox("Print?", vbYesNo Or vbQuestion) = vbYes Then
Mail.PrintOut
End If
End Sub
____________________________________________
<http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>
 
S

Stampie

So the full code should look like this...?

_____________________________________________
Private WithEvents Items As Outlook.Items
_____________________________________________
Private Sub Application_Startup()
Dim Ns As Outlook.NameSpace

Set Ns = Application.GetNamespace("MAPI")
Set Items = Ns.GetDefaultFolder(olFolderInbox).Items
End Sub
_____________________________________________
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
If TypeOf Item Is Outlook.MailItem Then
PrintNewItem Item
End If
End Sub
_____________________________________________
Private Sub PrintNewItem(Mail As Outlook.MailItem)
On Error Resume Next

If MsgBox("Print?", vbYesNo Or vbQuestion) = vbYes Then
If not Mail.GetInspector.Wordeditor is Nothing Then
Mail.GetInspector.WordEditor.PrintOut
Else
Mail.PrintOut
End if
End If
End Sub
____________________________________________


Using the above code, the lines of random text has disappeared from the
printed email, the To, Cc, Subject, etc fields are missing and the print
prompt still hides behind the email.

Are there any other options or should I admit defeat and install Office 2007?
 
Top