View Single Post
  #3  
Old May 18th 06, 12:32 PM posted to microsoft.public.outlook.program_vba
Nader
external usenet poster
 
Posts: 29
Default CDO & MailMessage problem

thanks.

"Sue Mosher [MVP-Outlook]" a écrit dans le message
de news: ...
You're mixing up two different CDO libraries. It's not your fault. Microsoft
caused a lot of confusion when they gave CDO for Windows (what you're using)
and CDO 1.21 (what has the saveCopy parameter) the same name. The Send
method in CDO for Windows has no saveCopy parameter; see
http://msdn.microsoft.com/library/en...af948785cb.asp

Bottom line is that, since you're sending directly through an SMTP server
and not through Outlook, you can't save it in Outlook's Sent Items folder.


--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"Nader" wrote in message
...
Hello,

I have written a code using vba and CDO object which works but I also
would
like to save a copy of the e-mail sent in the "Sent Items" folder in
outlook. So, I have looked into MSDN and found the answer

objMessage.Send( [saveCopy] [, showDialog] [, parentWindow] )

but it dose not work. I get an error ("wrong number of arguments or
invalid
property assignment")every time I run my add-in in outlook.

How can I make this work ?

Here's my code :

Public Sub sendFaxViaEmail(listOfAttachements as Collection)

Const cdoSendUsingPort = 2
Const cdoBasic = 1
Dim objCDOConfig As Object, objCDOMessage As Object
Dim strSch As String


strSch = "http://schemas.microsoft.com/cdo/configuration/"

Set objCDOConfig = CreateObject("CDO.Configuration")

With objCDOConfig.Fields
.Item(strSch & "sendusing") = cdoSendUsingPort
.Item(strSch & "smtpserver") = "mail.privagest.ch"
' Only used if SMTP server requires Authentication
'.Item(strSch & "smtpauthenticate") = cdoBasic
'.Item(strSch & "sendusername") = "
'.Item(strSch & "sendpassword") = "YourPassword"
.Update
End With

Set objCDOMessage = CreateObject("CDO.Message")

With objCDOMessage
Set .Configuration = objCDOConfig
.From = "Name_From"
.Sender = "
.To = "
'.Categories = "Privafax"
'.Subject = ""
'.Cc = ""
' Use TextBody to send Email in Plain Text Format
.TextBody = "::C=none,H,p=high"
' Use HTMLBody to send Email in Rich Text (HTML) Format
'.HTMLBody = "Test CDO Rich Text this is not Bold But BThis
is!/B"
' Un-Rem next line to get "Return Reciept Request"
'.MDNRequested = True
End With


If listOfAttachements.Count 0 Then
intCounter = 1
While intCounter listOfAttachements.Count + 1
objCDOMessage.AddAttachment listOfAttachements.Item(intCounter)
intCounter = intCounter + 1
Wend
End If

objCDOMessage.Send True '---------------- THE PROBLEM IS HERE !

MsgBox "Fax sent via e-mail.", vbInformation, "Privafax"

Set objCDOMessage = Nothing
Set objCDOConfig = Nothing

End Sub




Ads