代码中的错误请核心提示 [英] Errors in code pls corect it

查看:60
本文介绍了代码中的错误请核心提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public static void Send_mail(string strFrom, string StrTo, string StrSub, string StrBody, string StrCC, string strBcc, string EmailPass, string EmailUserName)
    {
        //StrCC = "";
        //strBcc = "";
        //EmailPass = "";
        //EmailUserName = "admin@admin.com";
        object sch = null;
        object cdoconfig = null;
        object cdomessage = null;
        object msgBodyPart = null;
        //Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory.
        const object cdoSendUsingPort = 2;
        //Send the message using the network (SMTP over the network).
        //Const cdoAnonymous = 0 'Do not authenticate
        const object cdoBasic = 1;
        //basic (clear-text) authentication
        //Const cdoNTLM = 2 'NTLM
        sch = "http://schemas.microsoft.com/cdo/configuration/";
        //cdoconfig = Server.CreateObject("CDO.Configuration")
        cdoconfig = CreateObject("CDO.Configuration");
        cdoconfig.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing").Value = cdoSendUsingPort;
        cdoconfig.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver").Value = "mail.demogiz.com";
        cdoconfig.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate").Value = cdoBasic;
        cdoconfig.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername").Value = "mark@demogiz.com";
        cdoconfig.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword").Value = "mark";
        cdoconfig.Fileds.update();
       cdomessage = CreateObject("CDO.Message");
       cdomessage.Configuration = cdoconfig;
        //System.Web.Mail.MailMessage cdomessage = new System.Web.Mail.MailMessage();
        //cdomessage.BodyFormat = MailFormat.Html;
        msgBodyPart = cdomessage.BodyPart;
        msgBodyPart.Charset = "UTF-8";
        msgBodyPart.ContentTransferEncoding = "quoted-printable";
        if (string.IsNullOrEmpty(strFrom))
        {
            strFrom = "Leelam Industries <admin@unitedhousing.com>";
        }
        cdomessage.From = strFrom.ToString();
        cdomessage.To = StrTo.ToString();
        cdomessage.CC = StrCC.ToString();
        cdomessage.BCC = strBcc;
        cdomessage.Subject = StrSub;
        cdomessage.HTMLBody = StrBody.ToString();
        try
        {
            cdomessage.Send();
        }
        catch (Exception ex)
        {
            break; // TODO: might not be correct. Was : Exit Try
        }
        cdomessage = null;
        cdoconfig = null;
    }


these error is marked in red color



由JSOP从repost添加:

错误列表为:

1. cdoSendUsingPort是``object''类型的.除字符串以外的引用类型的const字段只能用null初始化.

2.``对象''类型的cdoBasicis.除字符串以外的引用类型的const字段只能用null初始化.

3.名称CreateObject''在当前上下文中不存在

4. object不包含"Fields"的定义,找不到可以接受类型为"object"的第一个参数的扩展方法"Fields"(是否缺少using指令或程序集引用?)

5,object不包含``Configuration''的定义,找不到可以接受第一个类型为``object''的参数的扩展方法``Configuration''(是否缺少using指令或程序集引用?)

6.



Added By JSOP from repost:

The Error List Are:

1.cdoSendUsingPort is of type ''object''. A const field of a reference type other than string can only be initialized with null.

2.cdoBasicis of type ''object''. A const field of a reference type other than string can only be initialized with null.

3. The name CreateObject'' does not exist in the current context

4. object does not contain a definition for ''Fields'' and no extension method ''Fields'' accepting a first argument of type ''object'' could be found (are you missing a using directive or an assembly reference?)

5.object does not contain a definition for ''Configuration'' and no extension method ''Configuration'' accepting a first argument of type ''object'' could be found (are you missing a using directive or an assembly reference?)

6.

推荐答案

narendrarathod写道:
narendrarathod wrote:

break; //TODO:可能不正确.是:退出尝试

break; // TODO: might not be correct. Was : Exit Try



好吧,这只是愚蠢的.中断从循环中中断.您显然不知道自己在做什么.是什么让您认为此代码有错误?您是否考虑过告诉我们您做了什么调试,错误是什么等等?



Well, this is just stupid. Break breaks from a loop. You clearly have no idea what you''re doing. What makes you think there''s an error in this code ? Did you consider telling us what you''ve done the debug it, what the error is, etc ?

narendrarathod写道:
narendrarathod wrote:

这些错误标记为红色



哦,我懂了.除了,没有一个是红色的.我想再试一次.

=======================
从JSOP中(由于Comment功能似乎已损坏):

除了我可以更好地查找外,您和我非常相似...:)



Oh, I see. Except, none of it is in red. Try again, I guess.

=========================
From JSOP (since the Comment feature appears to be broken):

Except for the fact that I''m better lookin'', you and I are eerily similar... :)


如果您花时间在点击之前实际扫描了预览消息提交,您会发现红色没有伪装.

为什么不尝试在调试器下运行它,评估抛出的异常并修复代码?如果您需要我们的帮助来解决它,您将必须指示引发异常的行以及实际的异常.
If you had taken the time to actually scan the previewed message before clicking submit, you would have noticed that there is nothing makred in red.

Why don''t you try running it under the debugger, evaluating the exception that''s being thrown, and fix the code? If you want our help fixing it, you''re going to have to INDICATE what line is throwing the exception, and what the actual exception is.


在查看错误列表之后:

来吧-如果您自己做一些工作,这些都很容易修复.如果需要找出错误的含义,请使用google,然后将错误的理解与实际代码相关联.

我们不是在这里真正地修复您的代码,如果您考虑一下,我们真的不能,因为我们根本不熟悉所述代码的上下文.我们告诉您的任何事情都会产生我们无法预料的副作用和后果.那意味着你必须做腿部工作.

如果您不愿意为发现问题并自行解决而付出任何努力,为什么我们要花时间自己评估一下呢?
After looking at your list of errors:

C''mon - these are all easily fixable if you do a little work on your own. Use google if you need to find out what the error means, and then associate your undertsanding of the error with your actual code.

We''re not here to actually fix your code, and if you think about it, we really can''t because we aren''t at all familiar with the context of said code. Anythign we tell you could have side effects and ramifications that we can''t foresee. That means YOU have to do the leg work.

If you''re not willing to put any effort into recognizing problems and fixzing them on your own, why should we be bothered with taking the time to evaluate it ourselves?


这篇关于代码中的错误请核心提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆