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
You may want to check the total of all the file size before sending.
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...
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...
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...
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...
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...