CDO.Message

  • Thread starter Thread starter Chris
  • Start date Start date
C

Chris

I'm trying to send mail using the .Send method of the CDO.Message object (I
don't want to use doCmd.SendObject because of known issues and because I
want to add other attachments). I want to present the message dialog box
for the user to modify as needed, so thus need to set the second parameter
(of all three optional parameters) of the .Send method to 'true'. I keep
getting "wrong number of arguments or invalid property value assignment"
when I try to set this. E.g., ".Send ,True", ".Send False,True", ".Send
False,True,", ".Send 0,-1", etc. are all failing. What am I doing wrong? I
have otherwise had great success with using CDO in VBA. I believe I'm
setting these parameters correctly per MSDN documentation at:

http://msdn.microsoft.com/library/d...ry/en-us/cdo/html/_olemsg_overview_of_cdo.asp
 
Chris

Better Post your code, I don;t see how we can help without seeing what you
are trying to do. I have never use the Send method with any parameters. In
fact I really liked using the CDO library because I didn't have to rely on
the client to even have a MAPI Email app installed.

Ron W
 
Agreed, I like it for behind the scenes mailing also, but I want to add Word
attachments, and don't see that ye ole doCmd.SendObject (other popular
e-mail means) is going to let me.

Here's my routine (I've stripped out the application-y code which adds
attachments, but you get the idea). Per MSDN, my .SEND should be able to
take parameters, but it's not working:

Public Sub SendMail(strFrom As String, strRecipsTo As String, strRecipsCC As
String, _
strRecipsBCC As String, strSubject As String, _
strBody As String)

On Error GoTo Err_Routine

Dim l_Message As CDO.Message
Dim l_Configuration As CDO.Configuration

Set l_Configuration = New CDO.Configuration

With l_Configuration.Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "XXXXXXXXXXX"
.Update
End With

Set l_Message = New CDO.Message

With l_Message
Set .Configuration = l_Configuration

.To = strRecipsTo
.CC = strRecipsCC
.BCC = strRecipsBCC

.Subject = strSubject

.TextBody = strBody

.From = strFrom
.Sender = strFrom

.Send False, True

End With

Exit_Routine:
Set l_Message = Nothing
Set l_Configuration = Nothing
Exit Sub

Err_Routine:
LogError Err.Number, Err.Description, Err.Source, True
GoTo Exit_Routine

End Sub
 
Yup you are using it the same way I have in the past, where you specify a
SMTP server. However I don't think you can use it this way if you want to
have the message pop up for the user to edit, because there is no MAPI
object instantiated. Look at the example at
http://msdn.microsoft.com/library/d...ml/_olemsg_creating_and_sending_a_message.asp
to get an idea of what you need to do.

The example instantiates a MAPI Session and then uses that session to
instantiate a message object. I believ that is what you are going to have
to do to allow the user to edit the message before sending.

Ron W
 
Back
Top