By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,559 Members | 2,992 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,559 IT Pros & Developers. It's quick & easy.

Send Email and Attach

100+
P: 135
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.  
Oct 18 '09 #1

✓ answered 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 

Share this Question
Share on Google+
2 Replies


100+
P: 135
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 
Oct 18 '09 #2

NeoPa
Expert Mod 15k+
P: 31,494
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).
Oct 18 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.