• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 270
  • Last Modified:

Email Problem

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
jazamor
Asked:
jazamor
  • 7
  • 4
1 Solution
 
AxterCommented:
>>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
 
AxterCommented:
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
 
AxterCommented:
If you're using a string literal for your attached file, make sure that it has double \ characters

"c:\\windows\\system32\\somefile.txt"
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
AxterCommented:
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
 
jazamorAuthor Commented:
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
 
jazamorAuthor Commented:
I believe I downloaded it from your web site.
0
 
AxterCommented:
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
 
jazamorAuthor Commented:
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
 
AxterCommented:
>>SendEmail.cpp as is and call it from a main() function in myown.cpp ?

That's correct.
0
 
jazamorAuthor Commented:
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
 
AxterCommented:
>>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

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 7
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now