« Previous Next »

Thread: mail sending from asp.net

Last post 11-06-2006 3:22 AM by mvolo. 2 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (3 items)

Sort Posts:

  • 11-02-2006, 8:07 AM

    mail sending from asp.net

    Hi,

     I use the below code for sending mail. This is working fine in my local system. When I upload to my server it gives error:

    [COMException (0x80040220): The "SendUsing" configuration value is invalid.
    ]

    [TargetInvocationException: Exception has been thrown by the target of an invocation.]
       System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) +0
       System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters) +473
       System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) +58

    [HttpException (0x80004005): Could not access 'CDO.Message' object.]
       System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) +113
       System.Web.Mail.CdoSysHelper.Send(MailMessage message) +1846
       System.Web.Mail.SmtpMail.Send(MailMessage message) +150
       RFPProject.RFPProjInclude.mailFunction.mailFunction1(Int32 ConferenceID, String FromID, String TOId, String CCTypeID, String MessageSubject, String MessageBody)
       RFPProject.Web.UI.rfp_ForgotPassword.ButtonClick()
       RFPProject.Web.UI.rfp_ForgotPassword.Page_Load(Object sender, EventArgs e)
       System.Web.UI.Control.OnLoad(EventArgs e) +67
       System.Web.UI.Control.LoadRecursive() +35
       System.Web.UI.Page.ProcessRequestMain() +731

     

    The code what I am using for sending mail: 

    MailMessage msgMail = new MailMessage();

    msgMail.To = TOId;

    msgMail.Bcc = CCEmail;

    msgMail.From = FromID;

    msgMail.Subject = MessageSubject+ " from: " + host;

    msgMail.BodyFormat = MailFormat.Html;

    string strBody =TableVar; // "<html><body><b><font color=\'red\'><br>"+ MessageBogy +"</font></body></html>";

    msgMail.Body = strBody;

    //msgMail.Attachments.Add (new MailAttachment("C:\\Hari\\Desktop\\gm.jpg"));

    SmtpMail.Send(msgMail);

    return "MailSent";

    Please help me for this

  • 11-02-2006, 11:41 AM In reply to

    Re: mail sending from asp.net

    Where do you set your server name? web.config?
    Cheers
    Al

    My Blog
  • 11-06-2006, 3:22 AM In reply to

    • mvolo
    • Top 25 Contributor
    • Joined on 09-17-2003, 9:48 AM
    • Philadelphia, PA
    • Posts 584
    • IIS MVPs

    Re: mail sending from asp.net

    Check out this - http://www.systemwebmail.com/faq/4.2.2.aspx - for the 1 line solution to your problem.

    By the way, you should switch to using System.Net.Mail.  The System.Web.Mail class is obsolete - the System.Net version uses brand new .NET framework mail support as opposed to the legacy CDOSYS Windows component.

    Thanks,

    This posting is provided "AS IS" with no warranties, and confers no rights.
Page 1 of 1 (3 items)
Microsoft Communities