CDO & MailMessage problem

N

Nader

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") = "(e-mail address removed)"
'.Item(strSch & "sendpassword") = "YourPassword"
.Update
End With

Set objCDOMessage = CreateObject("CDO.Message")

With objCDOMessage
Set .Configuration = objCDOConfig
.From = "Name_From"
.Sender = "(e-mail address removed)"
.To = "(e-mail address removed)"
'.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 <B>This
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
 
S

Sue Mosher [MVP-Outlook]

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-us/cdosys/html/4485e9f7-54a7-426c-93c4-01af948785cb.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

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


Nader said:
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") = "(e-mail address removed)"
'.Item(strSch & "sendpassword") = "YourPassword"
.Update
End With

Set objCDOMessage = CreateObject("CDO.Message")

With objCDOMessage
Set .Configuration = objCDOConfig
.From = "Name_From"
.Sender = "(e-mail address removed)"
.To = "(e-mail address removed)"
'.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 <B>This
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
 
N

Nader

thanks.

"Sue Mosher [MVP-Outlook]" <[email protected]> a écrit dans le message
de news: (e-mail address removed)...
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-us/cdosys/html/4485e9f7-54a7-426c-93c4-01af948785cb.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

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


Nader said:
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") = "(e-mail address removed)"
'.Item(strSch & "sendpassword") = "YourPassword"
.Update
End With

Set objCDOMessage = CreateObject("CDO.Message")

With objCDOMessage
Set .Configuration = objCDOConfig
.From = "Name_From"
.Sender = "(e-mail address removed)"
.To = "(e-mail address removed)"
'.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 <B>This
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Sending E-mail 3
Sending E-Mail 11
WildCard 16
DoEvents 3
Using the CDO object to send email... 3
Form Not Visible 2
CDO Won't Send Across Domains 2
CDO Message 1

Top