View Single Post
  #1  
Old May 16th 06, 03:31 PM posted to microsoft.public.outlook.program_vba
Nader
external usenet poster
 
Posts: 29
Default CDO & MailMessage problem

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