RJHarvey72
asked on
Looking to create Outlook macro to automate fax sending
We use a fax from email solution that requires the user to enter in the recipient as [FAX:XXXXX] within Outlook where XXXXX is the fax number. This will then send it exchange and GFI Faxmaker.
I'd like to try make this a little more user friendly and therefore encourage users to use it.
Basically I want a button in outlook that will run a macro that will prompt the user for a phone number (it must start with 0) and when they click OK it will add the recipient as [FAX:whatever they enter]. It doesn't require to send the email just to avoid them having the enter the [FAX:XXXX] part.
If this script could also set the From part of the email as well that would be perfect. For example setting it to be departmentaFax@company.com .
Thanks
I'd like to try make this a little more user friendly and therefore encourage users to use it.
Basically I want a button in outlook that will run a macro that will prompt the user for a phone number (it must start with 0) and when they click OK it will add the recipient as [FAX:whatever they enter]. It doesn't require to send the email just to avoid them having the enter the [FAX:XXXX] part.
If this script could also set the From part of the email as well that would be perfect. For example setting it to be departmentaFax@company.com
Thanks
ASKER
Sid,
Thanks for taking the time to look at this. I think we are almost there. If we can simplify it a tiny bit then that will be perfect. All I'm looking to do is to prompt them for a fax number as you've done and hardset the From: part of the email. Once they've entered a valid number then all that will happen is that the email will look as below where XXXX is the number they've entered.
Many thanks
Richard
Thanks for taking the time to look at this. I think we are almost there. If we can simplify it a tiny bit then that will be perfect. All I'm looking to do is to prompt them for a fax number as you've done and hardset the From: part of the email. Once they've entered a valid number then all that will happen is that the email will look as below where XXXX is the number they've entered.
Many thanks
Richard
To send a FAX are you signed up with any "Fax Services" ?
The code that I gave above does what you want. See the line
Ret = SendFax(sFrom, sSubject, sFaxNo, sBody, sTo)
in the above code.
If you want to just display an email like in the snapshot above then use this code. You don't need to specify a "From" as it will go through the default account. For that, see this code.
Paste this code in a module in VBE Outlook.
Sid
The code that I gave above does what you want. See the line
Ret = SendFax(sFrom, sSubject, sFaxNo, sBody, sTo)
in the above code.
If you want to just display an email like in the snapshot above then use this code. You don't need to specify a "From" as it will go through the default account. For that, see this code.
Paste this code in a module in VBE Outlook.
Sub Sample()
Dim sFaxNo As String
Dim sSubject As String
Dim sBody As String
Dim Ret As Boolean
Dim objOutlookMsg As MailItem
Dim objOutlookRecip As Recipient
sSubject = "Hello World"
sBody = "I am hungry!!!"
sFaxNo = InputBox("Please enter the Fax Number, starting with '0'", "Fax Number")
If Len(Trim(sFaxNo)) = 0 Then
Exit Sub
Else
If Left(Trim(sFaxNo), 1) <> "0" Then
MsgBox "Incorrect Fax Number"
Sample
Exit Sub
Else
Set objOutlookMsg = Application.CreateItem(olMailItem)
With objOutlookMsg
'~~> Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add(sFaxNo)
objOutlookRecip.Type = olTo
'~~> Set the Subject and Body.
.Subject = sSubject
.Body = sBody
'~~> display the message
.Display
End With
End If
End If
End Sub
Sid
ASKER
Sid,
I don't need to use a Fax Service as we use a product called GFI Faxmaker which allows users to send/receive from Outlook. When they address the To part of the email as [FAX:XXXX] then it is routed to the Fax Server which then sends the faxes using ISDN. Depending on the FROM part of the email the recipient will see the fax as coming from a certain fax number. For example;
If the FROM is set to DepartmentAFax then it will show it as 01234567 whereas if it is sent from DepartmentBFax then it will show as having come from 01234568.
That's why I want to set the FROM part of the email .
The only other thing is that the TO part needs to be [FAX:XXXXX] as opposed to XXXXX.
If we can get those two minor things sorted then that is perfect.
Thanks again.
I don't need to use a Fax Service as we use a product called GFI Faxmaker which allows users to send/receive from Outlook. When they address the To part of the email as [FAX:XXXX] then it is routed to the Fax Server which then sends the faxes using ISDN. Depending on the FROM part of the email the recipient will see the fax as coming from a certain fax number. For example;
If the FROM is set to DepartmentAFax then it will show it as 01234567 whereas if it is sent from DepartmentBFax then it will show as having come from 01234568.
That's why I want to set the FROM part of the email .
The only other thing is that the TO part needs to be [FAX:XXXXX] as opposed to XXXXX.
If we can get those two minor things sorted then that is perfect.
Thanks again.
>>>The only other thing is that the TO part needs to be [FAX:XXXXX] as opposed to XXXXX.
For this
Add this line
before this line
in the above code.
Let me think about the "From" part.
Sid
For this
Add this line
sFaxNo = "[FAX:" & sFaxNo & "]"
before this line
Set objOutlookRecip = .Recipients.Add(sFaxNo)
in the above code.
Let me think about the "From" part.
Sid
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Brilliant, that's perfect.
Thanks again for your help.
Richard
Thanks again for your help.
Richard
You are welcome :)
Sid
Sid
Open in new window
Sid