jazamor
asked on
For Axter: RE:Email Problem
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","jaz amor@sandi a.gov","ja zamor@sand ia.gov"};
const char *BCCList[][64] = {"jazamor@sandia.gov","jaz amor@sandi a.gov","ja zamor@sand ia.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\S endEMail\E ntrustEmai l.cpp(20) : error C2676: binary '[' : 'class std::list<class std::basic_string<char,str uct std::char_traits<char>,cla ss std::allocator<char> >,class std::allocator<class std::basic_strin
g<char,struct std::char_traits<char>,cla ss 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\S endEMail\E ntrustEmai l.cpp(21) : error C2676: binary '[' : 'class std::list<class std::basic_string<char,str uct std::char_traits<char>,cla ss std::allocator<char> >,class std::allocator<class std::basic_strin
g<char,struct std::char_traits<char>,cla ss 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\S endEMail\E ntrustEmai l.cpp(22) : error C2676: binary '[' : 'class std::list<class std::basic_string<char,str uct std::char_traits<char>,cla ss std::allocator<char> >,class std::allocator<class std::basic_strin
g<char,struct std::char_traits<char>,cla ss 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\S endEMail\E ntrustEmai l.cpp(24) : error C2676: binary '[' : 'class std::list<class std::basic_string<char,str uct std::char_traits<char>,cla ss std::allocator<char> >,class std::allocator<class std::basic_strin
g<char,struct std::char_traits<char>,cla ss 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\S endEMail\E ntrustEmai l.cpp(25) : error C2676: binary '[' : 'class std::list<class std::basic_string<char,str uct std::char_traits<char>,cla ss std::allocator<char> >,class std::allocator<class std::basic_strin
g<char,struct std::char_traits<char>,cla ss 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\S endEMail\E ntrustEmai l.cpp(26) : error C2676: binary '[' : 'class std::list<class std::basic_string<char,str uct std::char_traits<char>,cla ss std::allocator<char> >,class std::allocator<class std::basic_strin
g<char,struct std::char_traits<char>,cla ss 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\S endEMail\E ntrustEmai l.cpp(32) : error C2064: term does not evaluate to a function
Error executing cl.exe.
EntrustEmail.obj - 7 error(s), 0 warning(s)
#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","jaz
const char *BCCList[][64] = {"jazamor@sandia.gov","jaz
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[
BCCList.push_back(BCCList[
BCCList.push_back(BCCList[
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\S
g<char,struct std::char_traits<char>,cla
C:\Documents and Settings\jazamor\Desktop\S
g<char,struct std::char_traits<char>,cla
C:\Documents and Settings\jazamor\Desktop\S
g<char,struct std::char_traits<char>,cla
C:\Documents and Settings\jazamor\Desktop\S
g<char,struct std::char_traits<char>,cla
C:\Documents and Settings\jazamor\Desktop\S
g<char,struct std::char_traits<char>,cla
C:\Documents and Settings\jazamor\Desktop\S
g<char,struct std::char_traits<char>,cla
C:\Documents and Settings\jazamor\Desktop\S
Error executing cl.exe.
EntrustEmail.obj - 7 error(s), 0 warning(s)
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>\"Davi d\"","<sen demailtest x1@altavis ta.com>\"B ill Gate\"","sendemailtestx2@a ltavista.c om","sende mailtestx3 @altavista .com "};
const char CCListTest[][64] = {"sendemailtestx4@altavist a.com","<s endemailte stx5@altav ista.com>\ "John Doe\"","sendemailtestx6@al tavista.co m"};
const char BCCListTest[][64] = {"sendemailtestx7@altavist a.com","se ndemailtes tx8@altavi sta.com"," sendemailt estx9@alta vista.com" };
void ExampleFunctionToSendMailT oMultipleT oCC_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(ToListTes t[0]);
ToList.push_back(ToListTes t[1]);
ToList.push_back(ToListTes t[2]);
std::list<std::string> CCList;
CCList.push_back(CCListTes t[0]);
CCList.push_back(CCListTes t[1]);
CCList.push_back(CCListTes t[2]);
std::list<std::string> BCCList;
BCCList.push_back(BCCListT est[0]);
BCCList.push_back(BCCListT est[1]);
BCCList.push_back(BCCListT est[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();
}
}
const char ToListTest[][64] = {"<davixd@axter.com>\"Davi
const char CCListTest[][64] = {"sendemailtestx4@altavist
const char BCCListTest[][64] = {"sendemailtestx7@altavist
void ExampleFunctionToSendMailT
{//Example for Multiple TO fields CC and BCC field
std::list<std::string> ToList;
ToList.push_back(ToListTes
ToList.push_back(ToListTes
ToList.push_back(ToListTes
std::list<std::string> CCList;
CCList.push_back(CCListTes
CCList.push_back(CCListTes
CCList.push_back(CCListTes
std::list<std::string> BCCList;
BCCList.push_back(BCCListT
BCCList.push_back(BCCListT
BCCList.push_back(BCCListT
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();
}
}
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","jaz amor@sandi a.gov","ja zamor@sand ia.gov"};
const char *BCCList[][64] = {"jazamor@sandia.gov","jaz amor@sandi a.gov","ja zamor@sand ia.gov"};
They're all pointers, and if you look at the original code example, I'm not using pointers.
const char BCCListTest[][64] = {"sendemailtestx7@altavist a.com","se ndemailtes tx8@altavi sta.com"," sendemailt estx9@alta vista.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.
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","jaz
const char *BCCList[][64] = {"jazamor@sandia.gov","jaz
They're all pointers, and if you look at the original code example, I'm not using pointers.
const char BCCListTest[][64] = {"sendemailtestx7@altavist
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.
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.
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.
ASKER
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Could you explain what a wrapper function is? And can you recommend a good c++ book?
>>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
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
*free* eBook
http://mindview.net/Books/TICPP/ThinkingInCPP2e.html
("Electronic book: Thinking in C++, Second Edition (Volumes 1 & 2)")
http://mindview.net/Books/TICPP/ThinkingInCPP2e.html
("Electronic book: Thinking in C++, Second Edition (Volumes 1 & 2)")
ASKER
Thanks, I'll go ahead an accept your answer and try to use what you have given me already. Thanks again for your help.
>>Thanks again for your help.
Your welcome :-)
Your welcome :-)
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.