Dim msg As New System.Web.Mail.MailMessage()        msg.To = [email protected]   '目标邮箱       
        msg.Subject = ...
        msg.Body = ...
        msg.Cc = ""
        ...        ' Add attachments to the msg
         Dim serverpath As String = ...  '附件路径
         Dim attachment As New System.Web.Mail.MailAttachment(serverpath)
         msg.Attachments.Add(attachment)
        
        System.Web.Mail.SmtpMail.SmtpServer = "10.172.100.100"  'SMTP服务器地址
        System.Web.Mail.SmtpMail.Send(msg)

解决方案 »

  1.   

    System.Web.Mail.SmtpMail.SmtpServer = "10.172.100.100"这个smtp代理
    服务器怎么得来的?
    我的是127.0.0.1 那么是否可以通过httpport2次代理才行呢?
    不要制定端口吗?
      

  2.   

    你用OUTLOOK发信时就有一个SMTP的服务器地址,用那个地址就可以了C#的代码和VB.NET的几乎完全一样,只要改改变量声名就行了
      

  3.   

    leeknife(刀刀李) 的代码 C#版:       System.Web.Mail.MailMessage msg=new System.Web.Mail.MailMessage();        msg.To = "[email protected]";  '目标邮箱       
            msg.Subject = ...;
            msg.Body = ...;
            msg.Cc = "";
            ...        // Add attachments to the msg
             string serverpath= ... ; //附件路径
             System.Web.Mail.Mailattachment attachment = New System.Web.Mail.MailAttachment(serverpath);
             msg.Attachments.Add(attachment);
            
            System.Web.Mail.SmtpMail.SmtpServer = "10.172.100.100";  //SMTP服务器地址
            System.Web.Mail.SmtpMail.Send(msg);
      

  4.   

    还是不大明白,leeknife(刀刀李)
    ,你的那个smtp服务器如果变了怎么办?一个smtp服务器可以传给
    不同网站的email吗??
    我的网络知识还不多,请指教
      

  5.   

    有一个可以发信的SMTP服务器就可以用代码发电子邮件了
    SMTP服务器变了你就改地址
    你用OUTLOOK时SMTP服务器地址变了你不是也要改地址的吗:)