Send Email and Attach | Member | | Join Date: Dec 2007 Location: Waterloo, NY
Posts: 89
| |
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. - 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. "
-
-
-
| |
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... ;-) - If IsNull([email]) Then
-
-
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. "
-
Else
-
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. "
-
-
End If
| | Member | | Join Date: Dec 2007 Location: Waterloo, NY
Posts: 89
| | | 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... ;-) - If IsNull([email]) Then
-
-
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. "
-
Else
-
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. "
-
-
End If
|  | Administrator | | Join Date: Oct 2006 Location: London - UK
Posts: 15,672
| | | 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).
|  | Similar Microsoft Access / VBA bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,272 network members.
|