Email attachment selection

Eljefegeneo

Still trying to learn
Local time
Today, 11:25
Joined
Jan 10, 2011
Messages
902
I use the fairly standard method of sending out an email blast with a provision for adding an attachment using
Code:
  .Attachments.Add (Attch)
Attch is a string.
Works fine if there is an attachment. But if there is no attachment by user selection, I get an error message that
Runtime error '-2147024809 (80070057)' Could not complete the operation. One or more parameters are not valid.

It is obvious to me that the code is looking for an attachment.
I tried the following but it did not solve the problem.
Code:
  If Not IsNull(txtAttachment) Then
  Attch = Me.txtAttachment
  Else: Attch = ""
  End If
I amended my code so that the user can select whether or not they want an attachment. But what I would like to know is how to amend the code to not include an attachment without having a second set of codes without the .Attachments.add(Attch) line.
I hope I am making sense. Just trying to simplify the code.




[FONT=&quot]Thanks[/FONT]
 
Code:
IF Nz(attch,"") <> "" THEN .Attachments.Add (Attch)
 
Thank you. I was hoping for such and answer.
 

Users who are viewing this thread

Back
Top Bottom