Solved

Need code to send email once test is complete

Posted on 2004-09-29
16
281 Views
Last Modified: 2010-05-18
The scenario:

We have numerous people running tests on the same computer throughout the  day.  I have a program that  runs through a test.  Currently it just gives you a pop-up once the test is complete on the test computer.  However, I want to shoot an email off to the tester once the test is complete. I will have to prompt the tester for his email before running the test and save it in a variable which will be used to send it.  I want it to be a generic email stating ' your test is now complete'.  I would like code to do this.  I have searched hi and low and have gotten close but everything I find just opens a new mail message window and you have to send.  I want it to send automatically.   Some explanation with the code would be great as I would like to understand whats going on.  Thanks!!
0
Comment
Question by:mnoel76
  • 7
  • 4
  • 4
  • +1
16 Comments
 
LVL 86

Assisted Solution

by:jkr
jkr earned 200 total points
ID: 12183153
If you are on Windows,  check out Microsoft's mail command line program at ftp://ftp.microsoft.com/softlib/mslfiles/smplmapi.EXE - it comes with full source code. Also check out the MSKB article at http://support.microsoft.com/default.aspx?scid=kb;en-us;171096 ("FILE: Simple MAPI Console Application"). On UN*X, spawning 'mailx' will help.
0
 
LVL 86

Expert Comment

by:jkr
ID: 12183179
BTW, another alternative might be http://www.codeproject.com/internet/zsmtp.asp ("CFastSmtp - Fast and easy SMTP class..."). Sending a mail can be just like

CFastSmtp mail;

if (mail.ConnectServer("SERVER")) {
    mail.SetSenderName("Sender's Name");
    mail.SetSenderEmail("senders@address.com");
    mail.SetSubject("CFastSmtp v1.1 Release");

    mail.AddRecipient("test@test.com");
    mail.AddCCRecipient("test@test.com");
    mail.AddBCCRecipient("test@test.com");

    mail.SetMessageBody("Here is another test of CFastSmtp SMTP class!");
   
    if (mail.GetConnectStatus()) {        
        printf(mail.Send() ? "Send was a success!" : "Send failed!");
        mail.Disconnect();                    
    }
}  
0
 

Author Comment

by:mnoel76
ID: 12183341
jkr

I will check into tonight as I can not download .exe at work.  I working on windows by the way.
0
 
LVL 86

Expert Comment

by:jkr
ID: 12183389
The CodeProject file is a zipped archive, if you can download that...
0
 
LVL 30

Accepted Solution

by:
Axter earned 300 total points
ID: 12183470
You can also try using the following code:
http://code.axter.com/SendEmail.cpp
http://code.axter.com/SendEmail.h

Above code has a wrapper function called SendEmailSimple.

Example usage of above code:

const char* Hostname = "axter_x.com";
const char* UserID = "axter_x";
const char* To = "maisonave@axter_x.com";
const char* Subject = "Your test is now complete";
const char* Body = "Auto-Notice: Your test is now complete";
SendEmailSimple(Hostname, UserID, To, Subject, Body);
0
 

Author Comment

by:mnoel76
ID: 12183487
jkr
checked out the codeproject.  where can I get the "stdafx.h" file that is included in the FastSmtp.cpp file
0
 

Author Comment

by:mnoel76
ID: 12183665
Axter
thanks for the code but it has to be win32.  we are not using MFC
0
 
LVL 30

Expert Comment

by:Axter
ID: 12184413
>>thanks for the code but it has to be win32.  we are not using MFC

Why do you think you need MFC?

It should be able to work on WIN32 application, with no MFC.

0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 30

Expert Comment

by:Axter
ID: 12184437
>>where can I get the "stdafx.h" file that is included in the FastSmtp.cpp

It should aready be part of your project.

If not, then just commented it out.
You only need it if your file is setup to compile with precompile settings.
0
 
LVL 5

Expert Comment

by:danielsonchris
ID: 12186321
mnoel,
the stdafx.h is used for precompiled headers.  Didn't the exe come with that?  I didn't download it.. so I don't really know.  Windows uses precompiled headers in order to aid in speeding up re-compiling software that may be large.  Basically it caches your include libraries that are placed in the stdafx.h for you.
Good luck,
Chris
0
 

Author Comment

by:mnoel76
ID: 12190420
Axter - to answer your first question I had another person look at the error I am getting when I run execute it, cannot open file "nafxcwd.lib".  Anyway this person said told that this is because we are not using MFC and will not be.  Obviously this is in correct.  Axter can you steer on how to proceed from here.  
Danielsonchris - thanks for the input.
0
 
LVL 86

Expert Comment

by:jkr
ID: 12191897
Have you already tried http://support.microsoft.com/default.aspx?scid=kb;en-us;171096 ("FILE: Simple MAPI Console Application")?
0
 

Author Comment

by:mnoel76
ID: 12191997
jkr - i didn't have a chance to try it last night.  I should have some time tonight and will get back to you.  thanks
0
 
LVL 30

Expert Comment

by:Axter
ID: 12192325
>>Axter - to answer your first question I had another person look at the error I am getting when I run execute
>>it, cannot open file "nafxcwd.lib".  

This error does not have anything to do with the code I posted.

The error is related as to how the project is build, and what libraries are being included.

Check your build options, and make sure you don't have this library included.

I recommend you test the code I posted, by creating a new console application, or Win32 APP.
You'll see it uses no MFC.
0
 

Author Comment

by:mnoel76
ID: 12192887
Axter
I have created a new Win32 App. When I execute I get a 0x0048eb1b referenced memory of 0x00000000 memory could not be 'read'.  Why is this happening
Bye the way appreciate the continued help.
0
 

Author Comment

by:mnoel76
ID: 12193557
jkr and Axater - I have found some source code that works properly.  I appreciate both your input I am going to split the points based on your help.  Thanks again!!
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

706 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

18 Experts available now in Live!

Get 1:1 Help Now