Access-Outlook

  • Thread starter Thread starter Abe Katz
  • Start date Start date
A

Abe Katz

Hello,

I'm using the following code to send email from Access.
The problem is, many times I only want to send an email without an
attachment.
How can I do it without duplicating the same code, just to ignore the
Attachments.Add line?
Thanks

With objEmail
.To = wEmailAdrs '"(e-mail address removed)"
.Subject = wSubject
.body = wBody
.Attachments.Add wOutPut
.Send
End With
 
add another input variable to your sub/function and check it to add the
attachment or not.

Function YourFunctionName(IncludeAtt as boolean)

.....

With objEmail
.To = wEmailAdrs '"(e-mail address removed)"
.Subject = wSubject
.body = wBody
If IncludeAtt=True then
.Attachments.Add wOutPut
End If
.Send
End With


End Function

Then when you call your function you use

YourFunctionName(True) 'To include the attachment
YourFunctionName(False) 'To exclude the attachment

Try it out, if you need further help, please post your entire routine and I
will revise it.
--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.
 
Back
Top