Friday, April 5, 2013

Printing incoming faxes - Elastix Forums :: Open Source Unified ...

HiLinks hidden for unregistered users. Login or register Here

I have been using Elastix for some time now, and happy to contribute back.
Like many, I did not use the fax service as I need all coming faxes to be printed and failed to find a viable solution.

Few days ago I have realised that I was looking at the problem from the wrong point of view, as it is far easier to have Elastix fax do it intended job sending the fax as an email attachment, and have the fax automaticaly printed at the outlook side.

enclosed is a sample of doing just that using outlook's VBA found at www.vboffice.net/sample.html?mnu=2&l...p=3&cmd=showitem Which I have tweeked a bit to have the email deleted after sucessful print.

Private Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Private WithEvents Items As Outlook.Items

Private Sub Application_Startup()
Dim Ns As Outlook.NameSpace
Dim Folder As Outlook.MAPIFolder

Set Ns = Application.GetNamespace("MAPI")
Set Folder = Ns.GetDefaultFolder(olFolderInbox)
Set Items = Folder.Items
End Sub

Private Sub Items_ItemAdd(ByVal Item As Object)
If TypeOf Item Is Outlook.MailItem Then
If PrintAttachments (Item) then Item.Delete
End If
End Sub

Private function PrintAttachments(oMail As Outlook.MailItem) as Boolean
On Error Resume Next
Dim colAtts As Outlook.Attachments
Dim oAtt As Outlook.Attachment
Dim sFile As String
Dim sDirectory As String
Dim sFileType As String

sDirectory = "c:\Attachments\"

Set colAtts = oMail.Attachments

If colAtts.Count Then
For Each oAtt In colAtts

sFileType = LCase$(right$(oAtt.FileName, 4))

Select Case sFileType
Case ".pdf"
sFile = sDirectory & oAtt.FileName
oAtt.SaveAsFile sFile
If (ShellExecute 0, "print", sFile, vbNullString, vbNullString, 0) > 32 then
PrintAttachments = True
Else
PrintAttachments = False
End If
End Select
Next
End If
End Sub

Hope this may help.

Erez

Source: http://www.elastix.org/index.php/en/component/kunena/26-tips-and-tricks/119541-printing-incoming-faxes.html

the river dr dog ke$ha earl csco big bend national park leon russell

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.