Connecting Tech Pros Worldwide Help | Site Map

Send Email and Attach

Member
 
Join Date: Dec 2007
Location: Waterloo, NY
Posts: 89
#1: Oct 18 '09
I have a database that I’ve created for creating/printing/sending purchase orders. It works great! Long live Access! Although, I have a slight problem with the sending part. I have a table for my suppliers that I pull some of the fields from to include in my main form for creating the purchase order. One of the fields is an email field that I have set as a hyperlink. If I click it and there is an email address in it then a new outlook email message will open, perfect. Here is the problem: I want to include as an attachment a pdf version of the purchase order. I have code that works great to output to a pdf. I have tried leaving the email field as a text field and then setting the onclick event to do a SendObject using the email address that is in the email field. It works nice and creates a message with the attached pdf. However, it only works as long as I have an address in my email field. If I click on the email field while it is blank I get an error. Even if the email field is blank I would then like to see a message open with the pdf attached and the address left blank. I could use a button instead, but I still get the error message if my email field is left blank. I hope this makes some sense. I just want to send a message with an attachment and include the address if there is one. Thanks in advance.
Expand|Select|Wrap|Line Numbers
  1. DoCmd.SendObjectacReport,"PurchaseOrder", acFormatPDF, Me.email , , , "Purchase Order", "The content of this email is the confidential property of the ####### and should not be copied, modified, retransmitted, or used for any purpose except with the #######'s written authorization.  If you are not the intended recipient, please delete all copies and notify us immediately. "
  2.  
  3.  
  4.  
best answer - posted by MyWaterloo
Praise God! It's amazing how many times I find my own solutions after I post. Thanks anyway. ...and it was such an easy fix... ;-)
Expand|Select|Wrap|Line Numbers
  1.  If IsNull([email]) Then
  2.  
  3. DoCmd.SendObject acReport, "PurchaseOrder", acFormatPDF, , , , "Purchase Order", "The content of this email is the confidential property of ###### and should not be copied, modified, retransmitted, or used for any purpose except with ######'s written authorization.  If you are not the intended recipient, please delete all copies and notify us immediately. "
  4. Else
  5. DoCmd.SendObject acReport, "PurchaseOrder", acFormatPDF, Me.Email, , , "Purchase Order", "The content of this email is the confidential property of ###### and should not be copied, modified, retransmitted, or used for any purpose except with ######'s written authorization.  If you are not the intended recipient, please delete all copies and notify us immediately. "
  6.  
  7. End If 
Member
 
Join Date: Dec 2007
Location: Waterloo, NY
Posts: 89
#2: Oct 18 '09

re: Send Email and Attach


Praise God! It's amazing how many times I find my own solutions after I post. Thanks anyway. ...and it was such an easy fix... ;-)
Expand|Select|Wrap|Line Numbers
  1.  If IsNull([email]) Then
  2.  
  3. DoCmd.SendObject acReport, "PurchaseOrder", acFormatPDF, , , , "Purchase Order", "The content of this email is the confidential property of ###### and should not be copied, modified, retransmitted, or used for any purpose except with ######'s written authorization.  If you are not the intended recipient, please delete all copies and notify us immediately. "
  4. Else
  5. DoCmd.SendObject acReport, "PurchaseOrder", acFormatPDF, Me.Email, , , "Purchase Order", "The content of this email is the confidential property of ###### and should not be copied, modified, retransmitted, or used for any purpose except with ######'s written authorization.  If you are not the intended recipient, please delete all copies and notify us immediately. "
  6.  
  7. End If 
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,672
#3: Oct 18 '09

re: Send Email and Attach


That's pretty well what I had to do in my print routine for reports. Unfortunately, as an omitted parameter is passed through as the Missing flag in a Variant variable, there is no way to specify this in code (that I know at least).
Reply