• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1053
  • Last Modified:

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

Hi experts,

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

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

how do i proceed
0
SirReadAlot
Asked:
SirReadAlot
  • 3
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
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.
0
 
SirReadAlotAuthor Commented:
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
0
 
SirReadAlotAuthor Commented:
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

thanks
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now