asmyatt
asked on
VBS ObjEmail Attach PDF - Gives error when opening attachment
I have a vb script that sends an email to a user and attaches a PDF document, but when the user opens the PDF the following errors occur:
Adobe Reader: An error exists on this page. Acrobat may not display the page correctly. Please contact the person who created the PDF document to correct the problem.
Adobe Reader: Cannot extract the embedded font 'QVFRVI+ArialMT'. Some characters may not be displayed or print correctly.
After the errors, all pages in the PDF are blank. The funny thing is I can view the PDF on the server and I can copy the PDF and manually move it to the users machine and it will open fine. We only receive these errors when is is sent in this script. Any ideas? Thanks.
Adobe Reader: An error exists on this page. Acrobat may not display the page correctly. Please contact the person who created the PDF document to correct the problem.
Adobe Reader: Cannot extract the embedded font 'QVFRVI+ArialMT'. Some characters may not be displayed or print correctly.
After the errors, all pages in the PDF are blank. The funny thing is I can view the PDF on the server and I can copy the PDF and manually move it to the users machine and it will open fine. We only receive these errors when is is sent in this script. Any ideas? Thanks.
Set CurrentUser = BOServer.MOContainer("Current User").Open("").DataObject
Set objEmail = CreateObject("CDO.Message")
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "exchange.com"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 27
objEmail.Configuration.Fields.Update
objEmail.From = CurrentUser.MWUser.Email
objEmail.To = ""
objEmail.AddAttachment "file://D:\Appraisals\"& Loanapp.LoanNumber &".pdf"
' Check For Processor Email Address
if not safeeval("LoanApp.Processor.Email") = "" then
objEmail.To = LoanApp.Processor.EMail
end if
'Set Subject line
objEmail.Subject = "Decision status changed to " & FieldValue & " on Loan " & LoanApp.AppNum
'Send Message
if objEmail.To <> "" then
objEmail.Send
end if
Set objEmail = nothing
Result = False
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
read a text file.....
' Read a Comma Separated Values file'
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objtextFile = objFSO.OpenTextFile(sFileInp , ForReading)
Do While objtextFile.AtEndOfStream <> True
strline = objtextFile.ReadLine
If InStr(strline, ",") Then 'found some values'
arrrecord = Split(strline, ",") 'split into array elements'
if ubound(arrrecord)=4 then
'looks like a fullrecord'
i = i + 1
sName = arrrecord(1)
sAddress = arrrecord(2)
lLoanNumber = arrRecord(3)
iFieldValue = arrRecord(4)
'create new message'
SendMail sName, sAddress, lLoanNumber, iFieldValue
End If
End If
Loop
objtextFile.Close
Set objtextFile = Nothing
Set objFSO = Nothing
Wscript.Echo "Sent " & i & " update messages"
Wscript.quit
'--------------------------------------------------------------'
Sub SendMail(sName, emailaddress, LoanNumber,FieldValue )
Dim objEmail
Set objEmail = CreateObject("CDO.Message")
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "exchange.com"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 27
objEmail.Configuration.Fields.Update
objEmail.From = "centralemail@123.com"
objEmail.To = emailaddress
objEmail.AddAttachment "file://D:\Appraisals\"& loannumber &".pdf"
'Set Subject line'
objEmail.Subject = "Decision status changed to " & FieldValue & " on Loan " & loannumber
'Send Message'
if objEmail.To <> "" then
objEmail.Send
end if
Set objEmail = nothing
End Sub
ASKER
So my question is on the email script, how can I make it grab the values from the txt file and store it as a variable (variables below would be emailaddress and loannumber). I would then use the variables for the To:, Attachment and Subject. See below.
Open in new window