Send E-mail

vnarod

Regular
Joined
Mar 22, 2002
Messages
84
I am trying to make my program to send an e-mail. I am getting the error "Could not access CDO.Message object".
I am not familiar with CDO. Do I need to add some reference? What should I do?

Dim oMail As New System.Web.Mail.MailMessage
With oMail
.From = "Management_reporting@ubs.com"
.To = "first.last@ubs.com"
.Subject = sFile
Dim myAttachment As System.Web.Mail.MailAttachment = New System.Web.Mail.MailAttachment(sFile)
.Attachments.Add(myAttachment)
End With

System.Web.Mail.SmtpMail.SmtpServer = "NNYCC001PEX1"
System.Web.Mail.SmtpMail.Send(oMail)
 
are you sure the System.Web is referenced correctly? and the smtp addy is correct? i just sent an e-mail to my addy with an attatchment without problem like this :
Visual Basic:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim wm As New Mail.MailMessage()
        Dim wa As New Mail.MailAttachment("C:\test.txt")
        With wm
            .Subject = "my subject"
            .To = "dynamic_sysop@msn.com"
            .From = "me"
            .Attachments.Add(wa)
            .BodyFormat = Web.Mail.MailFormat.Text
            .Body = "some text"
        End With
        Dim ws As Mail.SmtpMail
        ws.SmtpServer = "mail.hotmail.com"
        ws.Send(wm)
    End Sub
 
I copied your code and still got the same message.
I have system.web referenced. SMTP Server name I copy from Outlook(Microsoft Exchange Server property = NNYCC001PEX1).

What else I could do?
 
That error usually pops up when the SMTP server is not ready or running, or the application cant connect to it. Check if the Exchange server is up and running.
 
What should I check for? The Outlook is running. I thought that was an indication that SMTP server is fine. If I am wrong, please, tell me what I should do.
Are SMTP server and Microsoft Exchange Server same thing? I am using Microsoft Exchange Server name from Outlook.
 
No, they are not the same.

In order to use the CDO from .NET, you must have access to an SMTP Server; if you are using an NT-generation Operating System like Windows NT, 2K or XP, I believe there is an SMTP server installed with Internet Information Server. If you have installed it, you should be able to configure it from your IIS settings (Control Panel -> Administrative Tools -> Internet Information Services).
 
Did I understand you correctly that if a client does not have IIS installed he will not be able to send an e-mail from VB.NET program, even though he has Outlook?
 
That's not necessarily true; he just needs access to an SMTP server. In theory, you can use any SMTP server that he has access to (usually on a LAN or with an ISP), but if you wish to send mail directly through the client's computer, it will need some form of SMTP server installed on it.

Even Outlook requires you to type in server info in order for it to be able to work...


I may be way off base here, but that's how I think it is.
 
Last edited:
"That's not necessarily true; he just needs access to an SMTP server. In theory, you can use any SMTP server that he has access to (usually on a LAN or with an ISP), but if you wish to send mail directly through the client's computer, it will need some form of SMTP server installed on it."

Do you know of a method to detect the SMTP or to access it? Specifically, I know my SMTP is through TWC and I have its address.
 
I have a big problem with that too, where do you get these servers? I have XP and I can't find what you're talking about (IIS).

HELP MAE! IN THE WIN'! BBLLLAAHH!!! Over and out...
 
to be able to use IIS with XP , you must be running XP Professional. Then go to Add / Remove programmes ... Add / Remove Windows Components , then choose IIS.
IIS wont work on XP Home edition.
 
That's crack! Then how do I send e-mails using VB.NET?

----------------------

AAHHH!!!! IT WORKS THANKS YOU!! I HAVE HOME BTW LOL....

BUT JUST DOWNLOAD MSDE I THINK...AND THEN MY CODE IS:

Visual Basic:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim wm As New System.Web.Mail.MailMessage()

        With wm
            .Subject = "my subject"
            .To = "Diablicolic@msn.com"
            .From = "me"

            .BodyFormat = Web.Mail.MailFormat.Text
            .Body = "some text"
        End With
        Dim ws As System.Web.Mail.SmtpMail
        ws.SmtpServer = "mail.hotmail.com"
        ws.Send(wm)
    End Sub
 
Last edited:
Back
Top