Operator '==' cannot be applied to operands of type 'void' and 'bool'

Posted on 2007-09-28
Last Modified: 2008-01-09
Hi experts,

just trying to turn this smtp.Send(msg); into a boolean condition

            if (smtp.Send(msg) ==false)===========this line errors
            Console.WriteLine(" Successfull");

how do i proceed
Question by:SirReadAlot
    LVL 142

    Accepted Solution

    the error message means that the method Send does have a void return type, and not boolean.
    you CANNOT do that.
    you need to check if the object smtp has another property, that indicates if the Send was submitted sucessfully or not, or if there is an error message.

    Author Comment

    ok. back to this.

    smtp has no other property to state if items is delivered or not. but i  found this  class SmtpFailedRecipientsException which throws an exception if nothing was thrown

    Author Comment


    Author Comment

    hi angel,

    i think i fixed the problem by using this  smtp.SendAsync(mail, null);.

             SendAsync==Sends the specified e-mail message to an SMTP server for delivery. This method does not block the calling thread and allows the caller to pass an object to the method that is invoked when the operation completes.

    however is it wrong to use null


    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
    Article by: Najam
    Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now