Link to home
Start Free TrialLog in
Avatar of DAveB_LDS
DAveB_LDS

asked on

Attached PDF file opening as blank in email

I am creating a PDF file using "PowerPDF from NUance.
I use CDO to create an email sending the PDF as an attachment.
When the recipient opens the email (in gmail or outlook or whatever) it appears blank .

If I take the same PDF, open it and right click and "send email" no problem.email-0003.pdf
Avatar of John
John
Flag of Canada image

The PDF is a graphic, and the recipient may have images turned off (Outlook Default). Have the recipient go into Outlook, Options, Trust Center and allow images. That should work.
Avatar of Joe Winograd
Hi Dave,
I've had no problems with PDFs created by Nuance's Power PDF Advanced. Also, your attached file opens fine here, and based on your description, it seems that the CDO code is the problem. I suggest posting it here. The first idea that comes to mind is the SMTP server and the SendUsing parameter — are you using the local SMTP service or SMTP over the network? Here's some sample code that may be helpful:
http://www.paulsadowski.com/wsh/cdo.htm

Regards, Joe
Avatar of DAveB_LDS
DAveB_LDS

ASKER

Using Google SMTP server. See code
cdo-code.TXT
Code attached as per request
Dave,
I need to leave my office now for an hour or so. Will review your code as soon as I return. In the meantime, please clarify this statement of yours:
When the recipient opens the email (in gmail or outlook or whatever) it appears blank .
What appears blank? The email body? The PDF file? Both? If the PDF file is what's blank, how is it being opened from the email? More later, Joe
Thank you for your reply.
When you click to open the PDF. The PDF opens but the page is blank. All of the PDF documents are one page.
I have attached a sample.
email-0004.pdf
> When you click to open the PDF. The PDF opens but the page is blank.

Where is it opening? In Adobe Reader? In a tab in your browser? If the latter, which browser and which PDF plug-in?

Your CDO code is fine. I changed it slightly to this:
Set objMessage = CreateObject("CDO.Message")
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "myaccount@gmail.com"
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "mypassword"
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.Gmail.com"
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
objMessage.Configuration.Fields.Update
objMessage.Subject = "test pdf attachment"
objMessage.from = "myaccount@gmail.com"
objMessage.To = "myaccount@gmail.com"
Attachment1 = "d:\0tempd\expexch-email-0003.pdf"
objMessage.addAttachment Attachment1
objMessage.TextBody = "this is a test email to see if a pdf attachment works via cdo"
objMessage.Send

Open in new window

I tested sending to both a Gmail account and a Comcast account. I used your PDF file (expexch-email-0003.pdf) as the attachment. The PDF opened fine in both the Gmail and Comcast email web portals; and it also opened fine in the Thunderbird email client (both emails). So there's nothing wrong on the sending side. The problem is on the receiving side. Regards, Joe
Thank you.

Did you use my code to send?

I know that it works if I send manually.
> Did you use my code to send?

Yes. I used the code in my last post, which is your code with a few minor changes (didn't see a need for the variables). I put that code in a VBS file and ran it.
Leaving my office again, this time for several hours. Will check back into the thread as soon as I return to see how you're doing. Regards, Joe
I used VBScript to do the process - with the same results.
I changed the process to use the Outlook object instead of CDO and it worked perfectly.

Must have something to do with the CDO object under Windows 7?
ASKER CERTIFIED SOLUTION
Avatar of Joe Winograd
Joe Winograd
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I've abandoned the CDO solution and switched to using Outlook which is working perfectly.
I think the issue must be the CDO process or Windows.
I don't like to use Windows because if you use certain options it prompts on each email. In this case no prompting and no errors. Also catches invalid email addresses.

          Set outobj = CreateObject("Outlook.Application")
          Set mailobj = outobj.CreateItem(0)
         
            With mailobj
            .To = Recipient
            .Subject = Camper
            .Body = " "
            .Attachments.Add Attachment1
            .Send
          End With
         
          Set outobj = Nothing
          Set mailobj = Nothing
Good support even though the issue did not occur on his computer.
Dave,
Thanks for the update...and the kind words...really appreciate hearing them! That's a great solution you developed. Regards, Joe