A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

CDO & MailMessage problem



 
 
Thread Tools Search this Thread Display Modes
  #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
  #2  
Old May 16th 06, 04:10 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default CDO & MailMessage problem

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


  #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




 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with calendar item & Outlook 2003 Andreas Koepke Outlook - General Queries 1 March 17th 06 10:40 AM
Another problem with Symantec & Outlook JohnM Outlook - General Queries 1 February 24th 06 03:45 PM
mapi cdo service [email protected] Outlook - General Queries 8 February 20th 06 03:33 PM
Do i need Exchange for CDO A. Peters Outlook and VBA 4 February 18th 06 12:52 AM
Problem opening photo attachments & word documents donna Outlook Express 8 February 17th 06 03:40 AM


All times are GMT +1. The time now is 09:29 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.