469,648 Members | 1,709 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,648 developers. It's quick & easy.

Send Email and Attach

135 100+
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 

2 2448
MyWaterloo
135 100+
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
32,203 Expert Mod 16PB
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.

Similar topics

40 posts views Thread by ian | last post: by
1 post views Thread by Jeff West | last post: by
2 posts views Thread by oyster | last post: by
3 posts views Thread by =?Utf-8?B?SHVnaA==?= | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.