I'm using access 2010 and outlook 2010.
I'm trying to send eFaxes and we have a dedicated send from address. I can set the To: address and I believe I'm setting the from address. I only display the email and the from address is the current users address.
Private Sub EFax converts word docs to a pdf and then calls eFaxPDFemail
to attach it to the email and send it.
Please ignore all my attempts to fix this problem with lines now commented
I have set Olook to show the from address. If I send the mail eFax rejects the email because the from address on the outgoing mail is not the specific address registered as the authorised sending address.
Any help would be appreciated.
I'm trying to send eFaxes and we have a dedicated send from address. I can set the To: address and I believe I'm setting the from address. I only display the email and the from address is the current users address.
Private Sub EFax converts word docs to a pdf and then calls eFaxPDFemail
to attach it to the email and send it.
Please ignore all my attempts to fix this problem with lines now commented
Code:
Private Sub EFax_Click()
' eFax processing
'Converting docx to pdf
Dim wordApp As Word.Application
Dim wordDoc As Word.Document
Dim PdfName As String
Dim curPath As String
Dim DocName As String
curPath = Me.DocPathFld
DocName = Me.DocFileNameFld
FileExt = Right(DocFileName, Len(DocFileName) - InStrRev(DocFileName, "."))
If FileExt = "doc" Or FileExt = "docx" Or FileExt = "txt" Then
Set wordApp = CreateObject("Word.Application")
Set wordDoc = wordApp.Documents.Open(curPath & DocName)
PdfName = curPath & Left(DocName, (Len(DocName) - 5)) & ".pdf"
PdfFileNameFld = Left(DocName, (Len(DocName) - 5)) & ".pdf"
'PdfName = curPath & "\Some Folder\Converted Doc.pdf"
wordDoc.ExportAsFixedFormat OutputFileName:=PdfName, ExportFormat:= _
wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:=wdExportOptimizeForPrint, Range:=wdExportAllDocument, _
Item:=wdExportDocumentContent, IncludeDocProps:=True
wordDoc.Close saveChanges:=False
End If
'Now send via email
'Is there a Fax Number ?
Dim EmailAddress As String
Dim strFax As String
Dim ToUserEmail As String
If IsNull(Me.FaxFld) = True Then ' No Fax number
strFax = InputBox("There is no Fax Number on file would you like to enter one? Please include the area code. No spaces or brackets to be included.", "Information Required")
If IsNull(strFax) = True Then
Exit Sub ' it's not on file and they don't have one to enter
Else
ToUserEmail = "61" & Right(Trim(Me.FaxFld), 9) & "@efaxsend.com"
'ToUserEmail = Me.FaxFld & "@efaxsend.con"
End If
Else
ToUserEmail = "61" & Right(Trim(Me.FaxFld), 9) & "@efaxsend.com"
'ToUserEmail = Me.FaxFld
End If
Me.ToUserEmailFld = ToUserEmail
MsgBox " to email address = " & Me.ToUserEmailFld
Call eFaxPDFemail
End Sub
Public Function eFaxPDFemail()
' This will create the PDF if the report is setup for it
Dim strEmail As String
Dim strMsg As String
Dim oLook As Object
Dim oMail As Object
Dim strFromaddress As String
strFromaddress = "[EMAIL="efax@??????????.com.au"]efax@??????????.com.au[/EMAIL]"
MsgBox "Me.ToUserEmailFld = " & Me.ToUserEmailFld & "From Email Address = " & strFromaddress
'Set olAccount = strFromaddress
'Set oMail.sendusingaccount = olAccount
Set oLook = CreateObject("Outlook.Application")
Set oMail = oLook.createitem(0)
' Set oLook.SendUsingAccount = "[EMAIL="efax@??????????.com.au"]efax@??????????.com.au[/EMAIL]"
With oMail
.To = Me.ToUserEmailFld '"[EMAIL="recipientsfaxnumber@efaxsend.com"]recipientsfaxnumber@efaxsend.com[/EMAIL]"
.body = "Dear Sir / Madam" & Chr(10) & Chr(10) & "Please find enclosed a self explanatory communication from ?????? Pty. Ltd." & Chr(10) & Chr(10) & "Please discuss any enquiries with the author of the communication" & Chr(10) & Chr(10) & Chr(10) & Chr(10) & "Regards" & Chr(10) & Chr(10) & "????? Pty Ltd"
.Subject = "This is an eFax Communication from ?????????? Pty Ltd for your attention"
.Attachments.Add (DocPathFld & PdfFileNameFld)
.SendUsingAccount = "[EMAIL="efax@?????????.com.au"]efax@?????????.com.au[/EMAIL]"
'********* What is the command to preview instead of send **** .Display *****
.Display
End With
Set oMail = Nothing
Set oLook = Nothing
End Function
I have set Olook to show the from address. If I send the mail eFax rejects the email because the from address on the outgoing mail is not the specific address registered as the authorised sending address.
Any help would be appreciated.