CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2010
    Posts
    45

    My program doesn't work! Please help.

    Hello everyone. I made this little program for sending mail, everything looks fine (for me), got no errors, debugging without a problem. Only problem is that its not working. My program doesn't send mail. Can you please tell me why? Thanks.

    Code:
    
    // msdnproba2.cpp : main project file.
    
    #include "stdafx.h"
    #include <Windows.h>
    #include <iostream>
    #include <string>
    
    using namespace System;
    using namespace System::Net::Mail;
    using namespace System::Net;
    using namespace std;
    
    int main(array<System::String ^> ^args)
    {
    
      
      cout << "Sending mail..."<< endl;
    
      char f;
      cin >> f;
       
       
        return 0;
    }
    
     static void Mail_test1( String^ server, int port )
     {
    	 String^ to = L"[email protected]";
          String^ from = L"[email protected]";
          String^ subject = L"This is subject!";
          String^ body = L"Hello! This is a test.";
          MailMessage^ message = gcnew MailMessage( from,to,subject,body );
          SmtpClient^ client = gcnew SmtpClient( "smtp.mail.yahoo.com , 465" );
    
          
          client->Credentials = gcnew NetworkCredential("[email protected]", "mypassword", "smtp.mail.yahoo.com");
    	  client->UseDefaultCredentials = false;
          
          ServicePoint^ p = client->ServicePoint;
          Console::WriteLine( L"Connection lease timeout: {0}", p->ConnectionLeaseTimeout );
          client->Send( message );
    	  client->~SmtpClient();
    
    	 
     }

  2. #2
    Join Date
    Jul 2010
    Posts
    94

    Re: My program doesn't work! Please help.

    YOU don't need your input "f", why is it there ?
    You didn't call your function, only input your nonsense irrelevant f

  3. #3
    Join Date
    Jul 2010
    Posts
    45

    Re: My program doesn't work! Please help.

    Oh God. I didn't program for a WHILEEE. I forgot everything.
    I changed the problem now, but still my program doesn't work. Any clue?

    Code:
    // test3.cpp : main project file.
    
    #include "stdafx.h"
    #include <Windows.h>
    #include <iostream>
    #include <string>
    
    using namespace System;
    using namespace System::Net::Mail;
    using namespace System::Net;
    using namespace std;
    
    
    
    static void mailtest1 ( String^ server, int port )
     {
    	 String^ to = L"[email protected]";
          String^ from = L"[email protected]";
          String^ subject = L"This is subject!";
          String^ body = L"Hello! This is a test.";
          MailMessage^ message = gcnew MailMessage( from,to,subject,body );
          SmtpClient^ client = gcnew SmtpClient( "smtp.mail.yahoo.com , 465" );
    
    
    
          
          client->Credentials = gcnew NetworkCredential("[email protected]", "password", "smtp.mail.yahoo.com");
    	  client->UseDefaultCredentials = false;
          
          ServicePoint^ p = client->ServicePoint;
          Console::WriteLine( L"Connection lease timeout: {0}", p->ConnectionLeaseTimeout );
          client->Send( message );
    	  client->~SmtpClient();
    
    	 
     }
    
    
    
    
    
    int main(array<System::String ^> ^args)
    {
        mailtest1;
    
    		return 0;
    }

  4. #4
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    Re: My program doesn't work! Please help.

    You may want to ask in one of the .net forums.

  5. #5
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: My program doesn't work! Please help.

    Problem 1:
    Code:
    mailtest1 ( String^ server, int port )
    you never use server and port, why don't you get rid of them?

    Problem 2
    Code:
    int main(array<System::String ^> ^args)
    {
        mailtest1;
    
        return 0;
    }
    This shouldn't compile. You should call mailtest1() passing the right arguments, or if you get rid of the server and port parameters, without any arguments.
    Code:
    int main(array<System::String ^> ^args)
    {
        mailtest1();
    
        return 0;
    }
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  6. #6
    Join Date
    Jul 2010
    Posts
    45

    Re: My program doesn't work! Please help.

    I fixed that. Thanks for the reply , but my mail still isn't sent.

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

Featured