dbTalk Databases Forums  

CDO

comp.databases.ms-access comp.databases.ms-access


Discuss CDO in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Filips Benoit
 
Posts: n/a

Default CDO - 12-14-2009 , 12:06 PM






Dear All,

using function below without attachment send an email with an attachment
like ATT?????.dat.

What can i do about this.

Thanks,

Filips
--------------------------------------------------


Public Function SendCDOemail(Optional ToAddres As String, Optional
FromAddres As String, _
Optional CCAddres As String, Optional Subject As String, _
Optional MessageText As String, Optional Attachment1Path As String) As
Boolean
' set references to Microsoft Scripting Runtime AND Microsoft Office
12.0 Object Library
On Error GoTo ErrorMsgs

Dim objMessage As Object
Set objMessage = CreateObject("CDO.Message")
SendCDOemail = False

If Not IsMissing(ToAddres) Then
objMessage.To = ToAddres
End If
If Not IsMissing(FromAddres) Then
objMessage.FROM = FromAddres
End If
If Not IsMissing(CCAddres) Then
objMessage.CC = CCAddres
End If
If Not IsMissing(Subject) Then
objMessage.Subject = Subject
End If
If Not IsMissing(MessageText) Then
objMessage.TextBody = MessageText
End If
If Not IsMissing(Attachment1Path) Then
objMessage.AddAttachment Attachment1Path
End If
objMessage.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver")
= gsmtpserver '"uit.telenet.be"
objMessage.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing")
= 2
objMessage.Configuration.Fields.Update
objMessage.Send
Set objMessage = Nothing


SendCDOemail = True

Exit Function

Reply With Quote
  #2  
Old   
paii, Ron
 
Posts: n/a

Default Re: CDO - 12-14-2009 , 12:28 PM






If Not IsMissing(Attachment1Path) Then
strDirPath = Dir(Attachment1Path)
Do While strDirPath <> ""
objMessage.AddAttachment strDirPath
strDirPath = Dir()
Loop
End If

You may want to check the total of all the file size before sending.

Reply With Quote
  #3  
Old   
Filips Benoit
 
Posts: n/a

Default Re: CDO - 12-15-2009 , 12:54 PM



generates errormsg -21446697203 Unknown error !

my problem occures when the optinal parameter 'Attachment1Path' is missing
( not used)

Filips



"paii, Ron" <none (AT) no (DOT) com> wrote

Quote:
If Not IsMissing(Attachment1Path) Then
strDirPath = Dir(Attachment1Path)
Do While strDirPath <> ""
objMessage.AddAttachment strDirPath
strDirPath = Dir()
Loop
End If

You may want to check the total of all the file size before sending.


Reply With Quote
  #4  
Old   
paii, Ron
 
Posts: n/a

Default Re: CDO - 12-15-2009 , 02:34 PM



I don't understand how a missing Attachement1Path parameter could cause an
error. Both the code you supplied and I modified check that the parameter is
supplied before attempting to add an attachment. The code I supplied also
checks that the file exist before attempting to attach.

Which line is causing the error?

Note: strDirPath needs to be declared as type string in your function.

"Filips Benoit" <benoit.filips (AT) telenet (DOT) be> wrote

Quote:
generates errormsg -21446697203 Unknown error !

my problem occures when the optinal parameter 'Attachment1Path' is missing
( not used)

Filips



"paii, Ron" <none (AT) no (DOT) com> wrote in message
news:hg603j$abm$1 (AT) news (DOT) eternal-september.org...

If Not IsMissing(Attachment1Path) Then
strDirPath = Dir(Attachment1Path)
Do While strDirPath <> ""
objMessage.AddAttachment strDirPath
strDirPath = Dir()
Loop
End If

You may want to check the total of all the file size before sending.




Reply With Quote
  #5  
Old   
Filips Benoit
 
Posts: n/a

Default Re: CDO - 12-16-2009 , 02:41 PM



Hey,

The error occures here:
objMessage.AddAttachment strDirPath

BUT without the Attachement1Path parameter it still enters the new code
!!!!!!!!!!!!

Filip


"paii, Ron" <none (AT) no (DOT) com> wrote

Quote:
I don't understand how a missing Attachement1Path parameter could cause an
error. Both the code you supplied and I modified check that the parameter
is
supplied before attempting to add an attachment. The code I supplied also
checks that the file exist before attempting to attach.

Which line is causing the error?

Note: strDirPath needs to be declared as type string in your function.

"Filips Benoit" <benoit.filips (AT) telenet (DOT) be> wrote in message
news:h%QVm.23998$wc4.20483 (AT) newsfe20 (DOT) ams2...
generates errormsg -21446697203 Unknown error !

my problem occures when the optinal parameter 'Attachment1Path' is
missing
( not used)

Filips



"paii, Ron" <none (AT) no (DOT) com> wrote in message
news:hg603j$abm$1 (AT) news (DOT) eternal-september.org...

If Not IsMissing(Attachment1Path) Then
strDirPath = Dir(Attachment1Path)
Do While strDirPath <> ""
objMessage.AddAttachment strDirPath
strDirPath = Dir()
Loop
End If

You may want to check the total of all the file size before sending.






Reply With Quote
  #6  
Old   
paii, Ron
 
Posts: n/a

Default Re: CDO - 12-16-2009 , 03:06 PM



isMissing only works on Optional Variant types. Missing non Variant types
are set to the default value for that type. String type default is a zero
length string. Change your IF from isMissing(Attachment1Path) to
Attachment1Path <> "".

Sorry I don't use optional without defaults often and forgot about this bit
with isMissing.

"Filips Benoit" <benoit.filips (AT) telenet (DOT) be> wrote

Quote:
Hey,

The error occures here:
objMessage.AddAttachment strDirPath

BUT without the Attachement1Path parameter it still enters the new code
!!!!!!!!!!!!

Filip


"paii, Ron" <none (AT) no (DOT) com> wrote in message
news:hg8rsg$6cl$1 (AT) news (DOT) eternal-september.org...
I don't understand how a missing Attachement1Path parameter could cause
an
error. Both the code you supplied and I modified check that the
parameter
is
supplied before attempting to add an attachment. The code I supplied
also
checks that the file exist before attempting to attach.

Which line is causing the error?

Note: strDirPath needs to be declared as type string in your function.

"Filips Benoit" <benoit.filips (AT) telenet (DOT) be> wrote in message
news:h%QVm.23998$wc4.20483 (AT) newsfe20 (DOT) ams2...
generates errormsg -21446697203 Unknown error !

my problem occures when the optinal parameter 'Attachment1Path' is
missing
( not used)

Filips



"paii, Ron" <none (AT) no (DOT) com> wrote in message
news:hg603j$abm$1 (AT) news (DOT) eternal-september.org...

If Not IsMissing(Attachment1Path) Then
strDirPath = Dir(Attachment1Path)
Do While strDirPath <> ""
objMessage.AddAttachment strDirPath
strDirPath = Dir()
Loop
End If

You may want to check the total of all the file size before sending.








Reply With Quote
  #7  
Old   
Filips Benoit
 
Posts: n/a

Default Re: CDO - 12-17-2009 , 03:28 AM



Thanksł

Since all arguments are optional in this function I changed all arguments to
type Variant and the function runs OK now !
When I ommit the attachment-argument it now does not send annoying
ATT?????.dat as attachment.

By the way never heard of 'isMissing only works on Optional Variant types'
This will be usefull in the future so you made me happy today !

Filip



"paii, Ron" <none (AT) no (DOT) com> wrote

Quote:
isMissing only works on Optional Variant types. Missing non Variant types
are set to the default value for that type. String type default is a zero
length string. Change your IF from isMissing(Attachment1Path) to
Attachment1Path <> "".

Sorry I don't use optional without defaults often and forgot about this
bit
with isMissing.

"Filips Benoit" <benoit.filips (AT) telenet (DOT) be> wrote in message
news:KFbWm.15386$RF5.12573 (AT) newsfe02 (DOT) ams2...
Hey,

The error occures here:
objMessage.AddAttachment strDirPath

BUT without the Attachement1Path parameter it still enters the new code
!!!!!!!!!!!!

Filip


"paii, Ron" <none (AT) no (DOT) com> wrote in message
news:hg8rsg$6cl$1 (AT) news (DOT) eternal-september.org...
I don't understand how a missing Attachement1Path parameter could cause
an
error. Both the code you supplied and I modified check that the
parameter
is
supplied before attempting to add an attachment. The code I supplied
also
checks that the file exist before attempting to attach.

Which line is causing the error?

Note: strDirPath needs to be declared as type string in your function.

"Filips Benoit" <benoit.filips (AT) telenet (DOT) be> wrote in message
news:h%QVm.23998$wc4.20483 (AT) newsfe20 (DOT) ams2...
generates errormsg -21446697203 Unknown error !

my problem occures when the optinal parameter 'Attachment1Path' is
missing
( not used)

Filips



"paii, Ron" <none (AT) no (DOT) com> wrote in message
news:hg603j$abm$1 (AT) news (DOT) eternal-september.org...

If Not IsMissing(Attachment1Path) Then
strDirPath = Dir(Attachment1Path)
Do While strDirPath <> ""
objMessage.AddAttachment strDirPath
strDirPath = Dir()
Loop
End If

You may want to check the total of all the file size before sending.










Reply With Quote
Reply




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 On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.