Results 1 to 6 of 6

Thread: Send Mail Using C#

  1. #1

    Thread Starter
    Hyperactive Member Iron Skull's Avatar
    Join Date
    Aug 2005
    Location
    The Netherlands
    Posts
    325

    Send Mail Using C#

    I cant do this..
    I have this code:
    Code:
            static void Main(string[] args)
            {
                MailMessage mailMsg = new MailMessage();
                mailMsg .From = "[email protected]";
                mailMsg .To = "[email protected]";
                mailMsg .Cc = "[email protected]";
                mailMsg .Bcc = "[email protected]";
                mailMsg .Subject = "SubjectOfTheMailString";
                mailMsg .Body = "BodyOfTheMailString";
                smtpmail .Send(mailMsg); 
                Console.ReadKey();
            }
    And every line is an error.. Why?

    506C65617365205261746520506F7374732E2E2E

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: Send Mail Using C#

    you should declare the "smtpmail" object and use your mail server
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Send Mail Using C#

    Every line is an error? What error? If we don't know what the errors are we can't tell you what the errors are. Chances are you have added the required reference and/or import to your project. You haven't told us what version you're using so we don't know whether to advise you to use System.Web.Mail or System.Net.Mail. Please always specify your version when posting a question and always give details of errors. Otherwise we have to guess.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Send Mail Using C#

    My guess is, you're trying to use that C# code in a VB.NET application. That would be perfectly plausible since every line is an error.

  5. #5
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Send Mail Using C#

    Remove the space before the dynamic member access operator on each line.

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Send Mail Using C#

    D'oh.

    D'ohest thing ever.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width