A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Access-Outlook



 
 
Thread Tools Display Modes
  #1  
Old February 23rd, 2009, 07:36 PM posted to microsoft.public.access.forms
Abe Katz
external usenet poster
 
Posts: 43
Default Access-Outlook

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 "
.Subject = wSubject
.body = wBody
.Attachments.Add wOutPut
.Send
End With


  #2  
Old February 23rd, 2009, 09:09 PM posted to microsoft.public.access.forms
Daniel Pineault
external usenet poster
 
Posts: 658
Default Access-Outlook

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 "
.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.



"Abe Katz" wrote:

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 "
.Subject = wSubject
.body = wBody
.Attachments.Add wOutPut
.Send
End With



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:15 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.