?
Solved

For Axter: RE:Email Problem

Posted on 2004-09-27
11
Medium Priority
?
373 Views
Last Modified: 2010-04-01
I've tried your suggestion but am having problems.  Here is the code (used your example for multiple cc and bcc) and errors I get.  I hate to bother you but I really need help.  Thanks Joyce

#include "SendEmail.cpp"


int main()
      {
            const char* Hostname = "mailgate.sandia.gov";
            const char* UserID = "entrustt@sandia.gov";
            const char* To = "jazamor@sandia.gov";
            const char  *CCList[][64] = {"jazamor@sandia.gov","jazamor@sandia.gov","jazamor@sandia.gov"};
            const char  *BCCList[][64] = {"jazamor@sandia.gov","jazamor@sandia.gov","jazamor@sandia.gov"};
      
return 0;

}

void SendEmail(const std::string &Hostname, const std::string &UserID)
{
      std::list<std::string> CCList;
      CCList.push_back(CCList[0]);
      CCList.push_back(CCList[1]);
      CCList.push_back(CCList[2]);
      std::list<std::string> BCCList;
      BCCList.push_back(BCCList[0]);
      BCCList.push_back(BCCList[1]);
      BCCList.push_back(BCCList[2]);
      std::string Results = SendEmail(Hostname, UserID)(
             
            "*File Test x15: Please ignore this email.",
            "Test from SendEmail.  Please ignore this email.",
            &CCList,
            &BCCList);
      if (Results != SendEmail::NO_ERRORS)
      {
            printf("Error:\r\n");
            printf(Results.c_str());
            printf("\r\n\r\nPress ENTER to quit\r\n");
            getchar();
      }
}

These are the errors

Compiling...
EntrustEmail.cpp
C:\Documents and Settings\jazamor\Desktop\SendEMail\EntrustEmail.cpp(20) : error C2676: binary '[' : 'class std::list<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_strin
g<char,struct std::char_traits<char>,class std::allocator<char> > > >' does not define this operator or a conversion to a type acceptable to the predefined operator
C:\Documents and Settings\jazamor\Desktop\SendEMail\EntrustEmail.cpp(21) : error C2676: binary '[' : 'class std::list<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_strin
g<char,struct std::char_traits<char>,class std::allocator<char> > > >' does not define this operator or a conversion to a type acceptable to the predefined operator
C:\Documents and Settings\jazamor\Desktop\SendEMail\EntrustEmail.cpp(22) : error C2676: binary '[' : 'class std::list<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_strin
g<char,struct std::char_traits<char>,class std::allocator<char> > > >' does not define this operator or a conversion to a type acceptable to the predefined operator
C:\Documents and Settings\jazamor\Desktop\SendEMail\EntrustEmail.cpp(24) : error C2676: binary '[' : 'class std::list<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_strin
g<char,struct std::char_traits<char>,class std::allocator<char> > > >' does not define this operator or a conversion to a type acceptable to the predefined operator
C:\Documents and Settings\jazamor\Desktop\SendEMail\EntrustEmail.cpp(25) : error C2676: binary '[' : 'class std::list<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_strin
g<char,struct std::char_traits<char>,class std::allocator<char> > > >' does not define this operator or a conversion to a type acceptable to the predefined operator
C:\Documents and Settings\jazamor\Desktop\SendEMail\EntrustEmail.cpp(26) : error C2676: binary '[' : 'class std::list<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_strin
g<char,struct std::char_traits<char>,class std::allocator<char> > > >' does not define this operator or a conversion to a type acceptable to the predefined operator
C:\Documents and Settings\jazamor\Desktop\SendEMail\EntrustEmail.cpp(32) : error C2064: term does not evaluate to a function
Error executing cl.exe.

EntrustEmail.obj - 7 error(s), 0 warning(s)
0
Comment
Question by:jazamor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 3
11 Comments
 
LVL 30

Expert Comment

by:Axter
ID: 12163570
>>#include "SendEmail.cpp"

The above should be the following:
#include "SendEmail.h"

The main() function is not calling the SendEmail function, and it looks like the SendEmail function is calling itself.
0
 
LVL 30

Expert Comment

by:Axter
ID: 12163607
Here's a copy and paste of the example code listed in the bottom of the SendEmail.cpp file.

const char ToListTest[][64] = {"<davixd@axter.com>\"David\"","<sendemailtestx1@altavista.com>\"Bill Gate\"","sendemailtestx2@altavista.com","sendemailtestx3@altavista.com "};
const char CCListTest[][64] = {"sendemailtestx4@altavista.com","<sendemailtestx5@altavista.com>\"John Doe\"","sendemailtestx6@altavista.com"};
const char BCCListTest[][64] = {"sendemailtestx7@altavista.com","sendemailtestx8@altavista.com","sendemailtestx9@altavista.com"};

void ExampleFunctionToSendMailToMultipleToCC_AndBCC(const std::string &Hostname, const std::string &UserID, const std::string &UserPassword)
{//Example for Multiple TO fields CC and BCC field
      std::list<std::string> ToList;
      ToList.push_back(ToListTest[0]);
      ToList.push_back(ToListTest[1]);
      ToList.push_back(ToListTest[2]);
      std::list<std::string> CCList;
      CCList.push_back(CCListTest[0]);
      CCList.push_back(CCListTest[1]);
      CCList.push_back(CCListTest[2]);
      std::list<std::string> BCCList;
      BCCList.push_back(BCCListTest[0]);
      BCCList.push_back(BCCListTest[1]);
      BCCList.push_back(BCCListTest[2]);
      std::string Results = SendEmail(Hostname, UserID, UserPassword)(
            ToList,
            "*File Test x15x: Please ignore this email.",
            "Test from SendEmail.  Please ignore this email.",
            &CCList,
            &BCCList);
      if (Results != SendEmail::NO_ERRORS)
      {
            printf("Error:\r\n");
            printf(Results.c_str());
            printf("\r\n\r\nPress ENTER to quit\r\n");
            getchar();
      }
}
0
 
LVL 30

Expert Comment

by:Axter
ID: 12163654
In the code you posted, you're using the following variables that are inside the main() function:
          const char* Hostname = "mailgate.sandia.gov";
          const char* UserID = "entrustt@sandia.gov";
          const char* To = "jazamor@sandia.gov";
          const char  *CCList[][64] = {"jazamor@sandia.gov","jazamor@sandia.gov","jazamor@sandia.gov"};
          const char  *BCCList[][64] = {"jazamor@sandia.gov","jazamor@sandia.gov","jazamor@sandia.gov"};

They're all pointers, and if you look at the original code example, I'm not using pointers.
const char BCCListTest[][64] = {"sendemailtestx7@altavista.com","sendemailtestx8@altavista.com","sendemailtestx9@altavista.com"};

There's no asterik after "const char"

Also in your code you have the variable declared inside the main() but you did not pass these variables to your SendEmail function.
You should change the name of your function.  The function name is the same as the class name.
0
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.

 
LVL 30

Expert Comment

by:Axter
ID: 12163693
Are you planning on hard coding the variables?
How do you plan to initialize the variables like (Hostname, UserID, To, CCList, & BCCList).

I can give you a better example if I new the source of the data.
0
 

Author Comment

by:jazamor
ID: 12163846
Right now I plann on hard coding the variables for Hostname and UserID.  I would eventually like to read in a list of email addresse either in the CCList or BCCList.  

  I've taken classes on c++ programing but have never written one.  I am hoping to learn as I go because this is my first time trying to do & figure out a program.
0
 
LVL 30

Accepted Solution

by:
Axter earned 2000 total points
ID: 12164110
>>I've taken classes on c++ programing but have never written one.  I am hoping to learn as I go because this is my first
>>time trying to do & figure out a program.

I think you should make a wrapper function to simplify it.

I recommend not using pointers unless you really have to.

Hostname, UserID, and To variables are simple string variables, so you can initialize this like so:

const char Hostname[] = "mailgate.sandia.gov";
const char UserID[] = "entrustt@sandia.gov";
const char To[] = "jazamor@sandia.gov";

The CCList and BCCList variables are std::list type variables, and they're a little more complicated to initialize.

You could have a main function like the following:

#include <string>
#include <list>

#include "SendEmail.h"

int main()
{
     const char Hostname[] = "mailgate.sandia.gov";
     const char UserID[] = "entrustt@sandia.gov";
     const char To[] = "jazamor@sandia.gov";
     std::list<std::string> ToList;
     std::list<std::string> CCList ;
     std::list<std::string> BCCList;
     
     ToList.push_back(To);

     CCList .push_back("cc_user1@sandia.gov);
     CCList .push_back("cc_user2@sandia.gov);
     CCList .push_back("cc_use3@sandia.gov);

     BCCList.push_back("bcc_user1@sandia.gov);
     BCCList.push_back("bcc_user2@sandia.gov);
     BCCList.push_back("bcc_user3@sandia.gov);

     std::string Results = SendEmail(Hostname, UserID)(
          ToList,
          "*File Test x15x: Please ignore this email.",
          "Test from SendEmail.  Please ignore this email.",
          &CCList,
          &BCCList);
     if (Results != SendEmail::NO_ERRORS)
     {
          printf("Error:\r\n");
          printf(Results.c_str());
          printf("\r\n\r\nPress ENTER to quit\r\n");
          getchar();
     }
0
 

Author Comment

by:jazamor
ID: 12164313
Could you explain what a wrapper function is?  And can you recommend a good c++ book?
0
 
LVL 30

Expert Comment

by:Axter
ID: 12164352
>>Could you explain what a wrapper function is?  
A wrapper function is a function that simplifies more complex code.  It does most of the dirty work for you.


>>And can you recommend a good c++ book?

Check out the following links:
beginner's c++
http://www.accu.org/bookreviews/public/reviews/0sb/beginner_s_c__.htm

advanced c++
http://www.accu.org/bookreviews/public/reviews/0sb/advanced_c__.htm
0
 
LVL 30

Expert Comment

by:Axter
ID: 12164359
*free* eBook
http://mindview.net/Books/TICPP/ThinkingInCPP2e.html 
("Electronic book: Thinking in C++, Second Edition (Volumes 1 & 2)")
0
 

Author Comment

by:jazamor
ID: 12164374
Thanks, I'll go ahead an accept your answer and try to use what you have given me already.  Thanks again for your help.
0
 
LVL 30

Expert Comment

by:Axter
ID: 12164399
>>Thanks again for your help.

Your welcome :-)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

719 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