Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win



Posted on 2004-03-30
Medium Priority
Last Modified: 2007-12-19
I have a network here at work. I am going to have my computer as the main Server. I have another computer that will be used to sending mail. Do i need to setup the SMTP server ? If so where on my computer or the Mail Server ? Im a newbie at this so pls HELP! Here is the code:

'Set the smtp server
SmtpMail.SmtpServer = "greg"

'Send the email

An error occured while processing the email. Please review the following. Error sending email Could not access 'CDO.Message' object. Error String System.Web.HttpException: Could not access 'CDO.Message' object. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x80040213): The transport failed to connect to the server. --- End of inner exception stack trace --- at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) at System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters) at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) --- End of inner exception stack trace --- at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) at System.Web.Mail.CdoSysHelper.Send(MailMessage message) at System.Web.Mail.SmtpMail.Send(MailMessage message) at ClinicLogin.sendEmail.btnSend_Click(Object sender, EventArgs e) in C:\WEB_ROOT\WebForms\ClinicLogin\sendEmail.aspx.vb:line 164
Question by:jainpriyanka
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 10719082
you need to set up the box "greg" as an smtp server. you will also need to set it up as a mail relay. when you do this, you will only want to relay from specific machines, if possible. otherwise, if this is an externally availalbe server, your server will be a spam relay.

Expert Comment

ID: 10719573
Sorry..I don't quite get the idea. Its fine to have one more machine for sending the mails. That, I guess can be used as an exchange server or something like that. But for sending mail from your program, you can as well configure SMTP on your machine itself. Then, when you use the SMTP object and send a mail, if you are hooked on to the n/w, it will be configured to send the mail through the other machine set up for sending emails.

Diff parts of the code here..
using System.Web.mail;


MailMessage message = new MailMessage();
message.From = "name@urdomain.com";
message.to = "toname@domain.com"
message.subject = "";
message.body = "";


Note: Leave out the SMTPMail.SMTPServer = "greg" part. By default, it is initialized to ur localhost.


Expert Comment

ID: 10719685
this should help
i'm attaching a code for vb.net for a form that lets you send emails


Option Explicit On

Imports System.Web.Mail

Public Class frmEmail
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()

        'This call is required by the Windows Form Designer.

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
            End If
        End If
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents Panel1 As System.Windows.Forms.Panel
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents txtTo As System.Windows.Forms.TextBox
    Friend WithEvents txtFrom As System.Windows.Forms.TextBox
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents txtSubject As System.Windows.Forms.TextBox
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents cmdCancel As System.Windows.Forms.Button
    Friend WithEvents cmdEmailLog As System.Windows.Forms.Button
    Friend WithEvents txtContent As System.Windows.Forms.TextBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmEmail))
        Me.Panel1 = New System.Windows.Forms.Panel()
        Me.cmdCancel = New System.Windows.Forms.Button()
        Me.cmdEmailLog = New System.Windows.Forms.Button()
        Me.txtTo = New System.Windows.Forms.TextBox()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.txtFrom = New System.Windows.Forms.TextBox()
        Me.Label2 = New System.Windows.Forms.Label()
        Me.Label3 = New System.Windows.Forms.Label()
        Me.txtSubject = New System.Windows.Forms.TextBox()
        Me.txtContent = New System.Windows.Forms.TextBox()
        Me.Label4 = New System.Windows.Forms.Label()
        Me.Panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.Panel1.Controls.AddRange(New System.Windows.Forms.Control() {Me.cmdCancel, Me.cmdEmailLog, Me.txtTo, Me.Label1, Me.txtFrom, Me.Label2, Me.Label3, Me.txtSubject, Me.txtContent, Me.Label4})
        Me.Panel1.Location = New System.Drawing.Point(8, 32)
        Me.Panel1.Name = "Panel1"
        Me.Panel1.Size = New System.Drawing.Size(800, 376)
        Me.Panel1.TabIndex = 32
        Me.cmdCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.cmdCancel.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.cmdCancel.Location = New System.Drawing.Point(448, 336)
        Me.cmdCancel.Name = "cmdCancel"
        Me.cmdCancel.Size = New System.Drawing.Size(160, 32)
        Me.cmdCancel.TabIndex = 32
        Me.cmdCancel.Text = "     &Cancel"
        Me.cmdEmailLog.DialogResult = System.Windows.Forms.DialogResult.OK
        Me.cmdEmailLog.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.cmdEmailLog.Location = New System.Drawing.Point(280, 336)
        Me.cmdEmailLog.Name = "cmdEmailLog"
        Me.cmdEmailLog.Size = New System.Drawing.Size(160, 32)
        Me.cmdEmailLog.TabIndex = 31
        Me.cmdEmailLog.Text = "    &Send Email"
        Me.txtTo.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.txtTo.Font = New System.Drawing.Font("Courier New", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.txtTo.Location = New System.Drawing.Point(112, 8)
        Me.txtTo.Name = "txtTo"
        Me.txtTo.Size = New System.Drawing.Size(672, 20)
        Me.txtTo.TabIndex = 1
        Me.txtTo.Text = ""
        Me.Label1.Location = New System.Drawing.Point(8, 8)
        Me.Label1.Name = "Label1"
        Me.Label1.TabIndex = 0
        Me.Label1.Text = "To"
        Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        Me.txtFrom.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.txtFrom.Font = New System.Drawing.Font("Courier New", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.txtFrom.Location = New System.Drawing.Point(112, 32)
        Me.txtFrom.Name = "txtFrom"
        Me.txtFrom.Size = New System.Drawing.Size(672, 20)
        Me.txtFrom.TabIndex = 1
        Me.txtFrom.Text = ""
        Me.Label2.Location = New System.Drawing.Point(8, 32)
        Me.Label2.Name = "Label2"
        Me.Label2.TabIndex = 0
        Me.Label2.Text = "Your Email Addr."
        Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        Me.Label3.Location = New System.Drawing.Point(8, 56)
        Me.Label3.Name = "Label3"
        Me.Label3.TabIndex = 0
        Me.Label3.Text = "Subject"
        Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        Me.txtSubject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.txtSubject.Font = New System.Drawing.Font("Courier New", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.txtSubject.Location = New System.Drawing.Point(112, 56)
        Me.txtSubject.Name = "txtSubject"
        Me.txtSubject.Size = New System.Drawing.Size(672, 20)
        Me.txtSubject.TabIndex = 1
        Me.txtSubject.Text = ""
        Me.txtContent.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.txtContent.Font = New System.Drawing.Font("Courier New", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.txtContent.Location = New System.Drawing.Point(112, 80)
        Me.txtContent.Multiline = True
        Me.txtContent.Name = "txtContent"
        Me.txtContent.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
        Me.txtContent.Size = New System.Drawing.Size(672, 248)
        Me.txtContent.TabIndex = 1
        Me.txtContent.Text = ""
        Me.Label4.Location = New System.Drawing.Point(8, 80)
        Me.Label4.Name = "Label4"
        Me.Label4.TabIndex = 0
        Me.Label4.Text = "Content"
        Me.Label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(816, 416)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Panel1})
        Me.Font = New System.Drawing.Font("Verdana", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
        Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
        Me.MaximizeBox = False
        Me.Name = "frmEmail"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "Send Email"

    End Sub

#End Region


#End Region


#End Region


#End Region


#End Region


#End Region


#End Region

    Private Sub cmdEmailLog_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdEmailLog.Click
        If Me.txtTo.Text Is Nothing OrElse Me.txtTo.Text.Trim.Length < 1 OrElse _
            Me.txtFrom.Text Is Nothing OrElse Me.txtFrom.Text.Trim.Length < 1 OrElse _
            Me.txtSubject.Text Is Nothing OrElse Me.txtSubject.Text.Trim.Length < 1 OrElse _
            Me.txtContent.Text Is Nothing OrElse Me.txtContent.Text.Trim.Length < 1 Then

            MessageBox.Show("The email can not be sent since one or more is incomplete / blank:" & vbCrLf & " - To" & vbCrLf & " - From" & vbCrLf & " - Subject " & vbCrLf & " - Content", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Dim eml As New System.Web.Mail.MailMessage()
            With eml
                .To = Me.txtTo.Text
                .Bcc = Me.txtFrom.Text
                .From = Me.txtFrom.Text
                .Subject = Me.txtSubject.Text
                .Body = Me.txtContent.Text
                .Priority = MailPriority.High
                .BodyFormat = MailFormat.Text
            End With
            If MessageBox.Show("Send email?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
                    MessageBox.Show("The email has been successfully sent.", "Email", MessageBoxButtons.OK, MessageBoxIcon.Information)
                Catch ex As Exception
                    MessageBox.Show("The following error occured while sending email:" & vbCrLf & ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error)
                End Try
            End If
        End If
    End Sub
    Private Sub cmdCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCancel.Click
        '''If MessageBox.Show("Are you sure you want to close this form and discard all/any changes?", "Confirm Cancel", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) = DialogResult.Yes Then
        '''End If
    End Sub
#End Region

End Class

Author Comment

ID: 10724239
"Greg" is the computer on the network that has the email server running. I would prefer if i can just change settings on my computer and not on the Email Server. Please tell me how SMTP is to be configured from IIS on my computer and if I have to configure the Email server what will the steps be?

Accepted Solution

dummie_q earned 500 total points
ID: 10728204
Hi priyanka..
Usually when the IIS is installed on ur machine, the SMTp is also automatically configured.
Go to Start->Run
Type inetmgr
This will take to u to InetMgr Adm menu
Check to see if there is something like "Default SMTP virtual server"
Right click and go to "Properties"

In the General TAB make sure IP Addresses are set to "ALL Unassigned" ..guess this is deault.

Next go to Security tab: Here, ensure that permission is set for yourlogin..say "jainpriyanka"
Usually, by default, Administrators will have privilage. Alternatively, I guess, if you set the privilage for ur account as "Administrator" , it should work.

Thats all u need to do. Make sure you are in the same network as that of computer "GREG"
For example, if u r in the domain say, "TESTDOMAIN", then in ur inetmgr domain, if ur comp name is "jain", u will see "jain.TESTDOMAIN".
Similarly for "GREG", it will be "GREG.TESTDOMAIN".

This will ensure that all ur mails are routed thru GREG. Even otherwise, once u r on a n/w, ur SMTP can still manage to send ur email


Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question