?
Solved

Email Problem

Posted on 2004-09-23
11
Medium Priority
?
259 Views
Last Modified: 2011-04-14
I'm new - really new-idiot level- at programming and trying understand and use the SendEmail.cpp from Axter.  I used the example SendEmail Simple function to send an email to myself and it worked great.  Now, I've been trying to modify and use the program to read addresses from a text file and send mail to these addresses using the BCC field. I've tried the examples but can't make them to work - don't know how.  Can someone please help me?  Thanks.  
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
  • 7
  • 4
11 Comments
 
LVL 30

Expert Comment

by:Axter
ID: 12138002
>>I've tried the examples but can't make them to work - don't know how.  Can someone
>>please help me?  Thanks.  

Can you post your code.
Exactly how did it not work?   Did it fail to compile, fail to run, fail to send email, fail to send attachement with email......????

Give us as much details as you can.
0
 
LVL 30

Expert Comment

by:Axter
ID: 12138049
Example:

const char* Hostname = "axter_x.com";
const char* UserID = "axter_x";
const char* To = "maisonave@axter_x.com";
const char* Subject = "This is a test email";
const char* Body = "Test body";
const char* UserPassword = "abc123";

const char* AttachedFile = "C:\\autoexec.bat";

SendEmailSimple(Hostname, UserID, To, Subject, Body, UserPassword, AttachedFile);
0
 
LVL 30

Expert Comment

by:Axter
ID: 12138066
If you're using a string literal for your attached file, make sure that it has double \ characters

"c:\\windows\\system32\\somefile.txt"
0
Technology Partners: 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!

 
LVL 30

Expert Comment

by:Axter
ID: 12138089
Where did you get the SendEmail.cpp file from.
Was it from a link to my web site, or was it a copy and paste on another question?
0
 

Author Comment

by:jazamor
ID: 12138161
I'm sorry it's taken me so long to answer.  The code I used is yours exactly the way you have it.  I put in this from your examples

int main(int , char*)
      {
            const char* Hostname = "mailgate.sandia.gov";
            const char* UserID = "entrustt@sandia.gov";
            const char* To = "jazamor@sandia.gov";
            const char* Subject = "This is a test email";
            const char* Body = "Test body";
            SendEmailSimple(Hostname, UserID, To, Subject, Body);
            return 0;
      }      

const char CCListTest[][64] = {"jazamor@sandia.gov","jazamor@sandia.gov","jazamor@sandia.gov"};

const char BCCListTest[][64] = {"jazamor@sandia.gov","jazamor@sandia.gov","jazamor@sandia.gov"};

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();
      }
}

These are the errors I get.  My main problem is I don't understand what I'm doing.

Compiling...
SendEmail.cpp
C:\Documents and Settings\jazamor\Desktop\SendEMail\SendEmail.cpp(556) : error C2065: 'ToListTest' : undeclared identifier
C:\Documents and Settings\jazamor\Desktop\SendEMail\SendEmail.cpp(556) : error C2109: subscript requires array or pointer type
C:\Documents and Settings\jazamor\Desktop\SendEMail\SendEmail.cpp(556) : error C2664: 'push_back' : cannot convert parameter 1 from 'int' to 'const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &'
        Reason: cannot convert from 'int' to 'const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >'
        No constructor could take the source type, or constructor overload resolution was ambiguous
C:\Documents and Settings\jazamor\Desktop\SendEMail\SendEmail.cpp(557) : error C2109: subscript requires array or pointer type
C:\Documents and Settings\jazamor\Desktop\SendEMail\SendEmail.cpp(557) : error C2664: 'push_back' : cannot convert parameter 1 from 'int' to 'const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &'
        Reason: cannot convert from 'int' to 'const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >'
        No constructor could take the source type, or constructor overload resolution was ambiguous
C:\Documents and Settings\jazamor\Desktop\SendEMail\SendEmail.cpp(558) : error C2109: subscript requires array or pointer type
C:\Documents and Settings\jazamor\Desktop\SendEMail\SendEmail.cpp(558) : error C2664: 'push_back' : cannot convert parameter 1 from 'int' to 'const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &'
        Reason: cannot convert from 'int' to 'const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >'
        No constructor could take the source type, or constructor overload resolution was ambiguous
Error executing cl.exe.

SendEmail.obj - 7 error(s), 0 warning(s)
0
 

Author Comment

by:jazamor
ID: 12138179
I believe I downloaded it from your web site.
0
 
LVL 30

Accepted Solution

by:
Axter earned 2000 total points
ID: 12138325
It looks like you have modified the original SendEmail.cpp file.

The version posted on the web only has commented code with the keyword ToListTest

Also, line 556 on the posted version has the following:
      if (uc  < 26) return 'A'+uc;


Try downloading the file again, and use it without modifying it.
http://www.axter.com/code/SendEmail.cpp
http://www.axter.com/code/SendEmail.h

When you use SendEmail.cpp and SendEmail.h, you should be able to use them both without modifying the files.

You should call the functions or class from your code which should be in a different file.
Like:
main.cpp
or
myprogram.cpp

In your *.cpp file, add your main() function, and call the function from there.
0
 

Author Comment

by:jazamor
ID: 12138402
Okay, If I understand what your saying.  I can use your example for multiple CC and BCC field, at the end of the SendEmail.cpp as is and call it from a main() function in myown.cpp ?
0
 
LVL 30

Expert Comment

by:Axter
ID: 12139502
>>SendEmail.cpp as is and call it from a main() function in myown.cpp ?

That's correct.
0
 

Author Comment

by:jazamor
ID: 12143414
Okay, I'll give it a try. Since I new at this would it be okay to accept your answer for now and then post another question to you later if I have problems.  Thanks for your help.
0
 
LVL 30

Expert Comment

by:Axter
ID: 12144074
>>Thanks for your help.

Your welcome.

If you have any questions, or suggestions, feel free to posted here.

I have change this class before when I've received good suggestions for generic modification of the class.
0

Featured Post

Technology Partners: 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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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 be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

752 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