emailing in ASP.NET

Discussion in 'ASP .Net' started by Farooq Khan, Dec 29, 2003.

  1. Farooq Khan

    Farooq Khan Guest

    hi,
    i'm using CDONTS component for emailing through one of my web service like
    this

    // Start of code
    // 'email' is the CDONTS object name

    email.send(EmailFrom.ToString(), EmailTo.ToString(), Subject.ToString(),
    Body.ToString(), 1)

    // End of code


    the above call throws an exception with the message saying "Access is
    denied.". i'm using Windows 2000 Professional. don't know what i'm doing
    wrong over here. help me on this!!!

    Thanks.

    Farooq Khan
     
    Farooq Khan, Dec 29, 2003
    #1
    1. Advertising

  2. Farooq Khan

    Farooq Khan Guest

    i have even tried using Web.SmtpMail class' send() method for this.....but
    it throws "Could not access 'CDO.Message' object." exception.



    "Farooq Khan" <> wrote in message
    news:...
    > hi,
    > i'm using CDONTS component for emailing through one of my web service like
    > this
    >
    > // Start of code
    > // 'email' is the CDONTS object name
    >
    > email.send(EmailFrom.ToString(), EmailTo.ToString(), Subject.ToString(),
    > Body.ToString(), 1)
    >
    > // End of code
    >
    >
    > the above call throws an exception with the message saying "Access is
    > denied.". i'm using Windows 2000 Professional. don't know what i'm doing
    > wrong over here. help me on this!!!
    >
    > Thanks.
    >
    > Farooq Khan
    >
    >
     
    Farooq Khan, Dec 29, 2003
    #2
    1. Advertising

  3. Farooq Khan

    Hans Kesting Guest

    "Farooq Khan" <> wrote in message
    news:...
    > i have even tried using Web.SmtpMail class' send() method for this.....but
    > it throws "Could not access 'CDO.Message' object." exception.
    >
    >


    This "Could not access" message seems to be a general error message. The
    system
    usually CAN access that message object, the problem is further down.
    Somewhere in the InnerException list there are probably more useful
    errormessages.

    Hans Kesting
     
    Hans Kesting, Dec 29, 2003
    #3
  4. Farooq Khan

    Prodip Saha Guest

    Here is the function to send mail. Be sure to use System.Web.Mail namespace.

    Prodip Saha

    public bool SendSMTPMail(string strSMTPServer, string strFrom, string strTo,
    string strSubject, string strBody, string strCC, string strBCC, string
    strAttachmentList, bool blnUseHTML)
    {
    bool blnTemp=false;
    try
    {
    MailMessage objMsg = new MailMessage();
    objMsg.From = strFrom;
    objMsg.To = strTo;
    objMsg.Subject = strSubject;
    objMsg.Body = strBody;
    if (strCC !="")
    {
    objMsg.Cc = strCC;
    }
    if (strBCC !="")
    {
    objMsg.Bcc = strBCC;
    }
    if(blnUseHTML==true)
    {
    objMsg.BodyFormat=MailFormat.Html;
    }
    else
    {
    objMsg.BodyFormat=MailFormat.Text;
    }

    // Build an IList of mail attachments.
    //A list of files separated by comma(,)
    if (strAttachmentList != "")
    {
    char[] delim = new char[] {','};
    foreach (string sSubstr in strAttachmentList.Split(delim))
    {
    MailAttachment attachment = new MailAttachment(sSubstr);
    objMsg.Attachments.Add(attachment);
    }
    }

    SmtpMail.SmtpServer = strSMTPServer;
    SmtpMail.Send(objMsg);
    blnTemp=true;

    return blnTemp;

    }
    catch(Exception ex)
    {
    throw ex;
    }
    }

    "Farooq Khan" <> wrote in message
    news:...
    > hi,
    > i'm using CDONTS component for emailing through one of my web service like
    > this
    >
    > // Start of code
    > // 'email' is the CDONTS object name
    >
    > email.send(EmailFrom.ToString(), EmailTo.ToString(), Subject.ToString(),
    > Body.ToString(), 1)
    >
    > // End of code
    >
    >
    > the above call throws an exception with the message saying "Access is
    > denied.". i'm using Windows 2000 Professional. don't know what i'm doing
    > wrong over here. help me on this!!!
    >
    > Thanks.
    >
    > Farooq Khan
    >
    >
     
    Prodip Saha, Dec 29, 2003
    #4
  5. Farooq Khan

    Farooq Khan Guest

    thanks saha,
    but it doesn't work either. infact that's exactly what i have been doing.
    dont know what is wrong with it. anyway thanks for ur help.

    Farooq Khan


    "Prodip Saha" <> wrote in message
    news:...
    > Here is the function to send mail. Be sure to use System.Web.Mail

    namespace.
    >
    > Prodip Saha
    >
    > public bool SendSMTPMail(string strSMTPServer, string strFrom, string

    strTo,
    > string strSubject, string strBody, string strCC, string strBCC, string
    > strAttachmentList, bool blnUseHTML)
    > {
    > bool blnTemp=false;
    > try
    > {
    > MailMessage objMsg = new MailMessage();
    > objMsg.From = strFrom;
    > objMsg.To = strTo;
    > objMsg.Subject = strSubject;
    > objMsg.Body = strBody;
    > if (strCC !="")
    > {
    > objMsg.Cc = strCC;
    > }
    > if (strBCC !="")
    > {
    > objMsg.Bcc = strBCC;
    > }
    > if(blnUseHTML==true)
    > {
    > objMsg.BodyFormat=MailFormat.Html;
    > }
    > else
    > {
    > objMsg.BodyFormat=MailFormat.Text;
    > }
    >
    > // Build an IList of mail attachments.
    > //A list of files separated by comma(,)
    > if (strAttachmentList != "")
    > {
    > char[] delim = new char[] {','};
    > foreach (string sSubstr in strAttachmentList.Split(delim))
    > {
    > MailAttachment attachment = new MailAttachment(sSubstr);
    > objMsg.Attachments.Add(attachment);
    > }
    > }
    >
    > SmtpMail.SmtpServer = strSMTPServer;
    > SmtpMail.Send(objMsg);
    > blnTemp=true;
    >
    > return blnTemp;
    >
    > }
    > catch(Exception ex)
    > {
    > throw ex;
    > }
    > }
    >
    > "Farooq Khan" <> wrote in message
    > news:...
    > > hi,
    > > i'm using CDONTS component for emailing through one of my web service

    like
    > > this
    > >
    > > // Start of code
    > > // 'email' is the CDONTS object name
    > >
    > > email.send(EmailFrom.ToString(), EmailTo.ToString(), Subject.ToString(),
    > > Body.ToString(), 1)
    > >
    > > // End of code
    > >
    > >
    > > the above call throws an exception with the message saying "Access is
    > > denied.". i'm using Windows 2000 Professional. don't know what i'm doing
    > > wrong over here. help me on this!!!
    > >
    > > Thanks.
    > >
    > > Farooq Khan
    > >
    > >

    >
    >
     
    Farooq Khan, Dec 30, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stephen

    emailing passwords using .NET

    Stephen, Jul 20, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    386
    R.Balaji
    Jul 23, 2004
  2. Mark Rodseth

    .NET emailing problem

    Mark Rodseth, Apr 21, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    393
  3. =?Utf-8?B?TWlrZSBNb29yZQ==?=

    Emailing From Asp.net

    =?Utf-8?B?TWlrZSBNb29yZQ==?=, Jul 29, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    408
    Jim Cheshire [MSFT]
    Sep 30, 2004
  4. John Smith

    ASP.NET Emailing

    John Smith, Nov 4, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    2,366
    John Smith
    Nov 5, 2004
  5. Replies:
    9
    Views:
    1,288
Loading...

Share This Page