Access-Outlook

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
 
D

Daniel Pineault

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top