469,603 Members | 2,069 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,603 developers. It's quick & easy.

Sending more than one attachment

Recently I tried to develop a function to help me sending e-mail messages
with more than one attachment. Everything is working OK when I am sebding
messages with one attachment, but when I try to send more than one file as
attachment I get the following error:
-------- Error -----------------
Could not access 'CDO.Message' object.
at System.Web.Mail.LateBoundAccessHelper.CallMethod(O bject obj, String
methodName, Object[] args) at System.Web.Mail.CdoSysHelper.Send(MailMessage
message) at System.Web.Mail.SmtpMail.Send(MailMessage message) at
GlendaleInfo.ReadFile.SendMail(String SendTo, String SentFrom, String
MessageSubject, String MessageBody, MailFormat MessageType, String
MailAttachments) in ....

----------------> End Error

Here is my code which tries to attach the the files and send the message:
' Creating the email object
Dim oMail As MailMessage = New MailMessage
' Creating the attachment object

'*********************************************
' Checking if there is some attachments
'*********************************************
If MailAttachments <> "" Then
Dim FilesToAttach() As String
Dim j As Integer
FilesToAttach = Split(MailAttachments, ",")

For j = 0 To UBound(FilesToAttach)
' Create the mail attachment
Dim oMailAttachment As MailAttachment = New
MailAttachment(FilesToAttach(j))
' Adding the attachment/s to the email message
oMail.Attachments.Add(oMailAttachment)
Next

SmtpMail.SmtpServer = ""
End If

' Create de message
'oMail = New MailMessage
oMail.To = SendTo
oMail.From = SentFrom
' Body format
oMail.BodyFormat = MessageType
oMail.Priority = MailPriority.High
'Message subject
oMail.Subject = MessageSubject
' Message body
oMail.Body = MessageBody
'sending e message
SmtpMail.Send(oMail)
Nov 17 '05 #1
0 1339

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Paul Lamonby | last post: by
3 posts views Thread by Jared | last post: by
5 posts views Thread by morphex | last post: by
6 posts views Thread by Anuradha | last post: by
reply views Thread by guiromero | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.