Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CDO

17 views
Skip to first unread message

Filips Benoit

unread,
Dec 14, 2009, 1:06:17 PM12/14/09
to
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


paii, Ron

unread,
Dec 14, 2009, 1:28:00 PM12/14/09
to

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.


Filips Benoit

unread,
Dec 15, 2009, 1:54:43 PM12/15/09
to
generates errormsg -21446697203 Unknown error !

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

Filips

"paii, Ron" <no...@no.com> wrote in message
news:hg603j$abm$1...@news.eternal-september.org...

paii, Ron

unread,
Dec 15, 2009, 3:34:21 PM12/15/09
to
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...@telenet.be> wrote in message
news:h%QVm.23998$wc4....@newsfe20.ams2...

Filips Benoit

unread,
Dec 16, 2009, 3:41:49 PM12/16/09
to
Hey,

The error occures here:
objMessage.AddAttachment strDirPath

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

Filip


"paii, Ron" <no...@no.com> wrote in message

news:hg8rsg$6cl$1...@news.eternal-september.org...

paii, Ron

unread,
Dec 16, 2009, 4:06:37 PM12/16/09
to
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...@telenet.be> wrote in message

news:KFbWm.15386$RF5....@newsfe02.ams2...

Filips Benoit

unread,
Dec 17, 2009, 4:28:49 AM12/17/09
to
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" <no...@no.com> wrote in message

news:hgbi50$kok$1...@news.eternal-september.org...

0 new messages