Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    About PopupEditText and SendMail

    Cinema 4D SDK
    r20 c++
    3
    12
    2.5k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      anoano
      last edited by

      PopupEditText and SendMail changed from R20.
      Even if I look at the C++ SDK, I can not find the sample so I can not figure out how to write the code.
      Please let me know.

      1 Reply Last reply Reply Quote 0
      • M
        m_adam
        last edited by m_adam

        Hi @anoano, first of all, I would like to point you to our Q&A functionality please use it. 😉
        As you figured PopupEditText has changed, the func parameter was a PopupEditTextCallback and now it's a maxon:: Delegate.

        About SendMail, it was removed and replaced by a totally new interface SmtpMailInterface.

        Here a basic example which makes use of both.

        class CommandSendEmail : public CommandData
        {
        	INSTANCEOF(CommandSendEmail, CommandData)
        private:
        	String txt;
        
        public:
        	void MailRecieverChangeCallback(POPUPEDITTEXTCALLBACK nMode, const maxon::String& text)
        	{
        		switch (nMode)
        		{
        		case POPUPEDITTEXTCALLBACK::TEXTCHANGED:
        			GePrint(text);
        			break;
        		case POPUPEDITTEXTCALLBACK::CLOSED:
        			txt = text;
        			SendEmail();
        			break;
        
        		default:
        			break;
        		}
        	};
        
        	Bool SendEmail()
        	{
        		// Create a reference to smtpMailInterface
        		iferr(maxon::SmtpMailRef smtp = maxon::SmtpMailRef::Create())
        			return false;
        
        		// Define the subject
        		iferr(smtp.SetSubject("Email Send from C4d"_s))
        			return false;
        
        		// Define the sender
        		iferr(smtp.SetSender("[email protected]"_s, "Random Email"_s))
        			return false;
        
        		// Add text to this email
        		iferr(smtp.AttachText("This is the content of the email"_s))
        			return false;
        
        		// Define the list of receiver
        		maxon::SmtpReceiver receiverList[] = { maxon::SmtpReceiver(txt, maxon::String()) };
        		iferr(smtp.SetReceiver(receiverList))
        			return false;
        
        		// Define our login/password
        		iferr(smtp.SetUserPassword("UserName"_s, "Password"_s))
        			return false;
        
        		// Finally send the email with your SMTP server and port 25
        		iferr(smtp.SendMimeMail("SMTPServer"_s, 25))
        			GePrint(err.GetMessage());
        		else
        			GePrint("Email sent to:" + txt);
        
        		return true;
        	};
        
        	Bool Execute(BaseDocument* doc)
        	{
        		if (!doc)
        			return false;
        		PopupEditText(0, 0, 200, 50, "Email Receiver"_s, [this](POPUPEDITTEXTCALLBACK index, maxon::String& name) { MailRecieverChangeCallback(index, name); });
        
        		return true;
        	};
        	static CommandSendEmail* Alloc() { return NewObjClear(CommandSendEmail); }
        };
        
        

        Note that you can find all the changes in API Change List in R20.

        If you have any questions please let me know.
        Cheers,
        Maxime!

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        1 Reply Last reply Reply Quote 2
        • A
          anoano
          last edited by

          Thank you for making the sample.
          I tried it immediately, but I got an error with maxon :: SmtpReceiver.
          I want to include network_smtpmail.h but I do not know the location of the file.
          Where is the file?

          1 Reply Last reply Reply Quote 0
          • A
            anoano
            last edited by

            You can now use it after adding a path.

            1 Reply Last reply Reply Quote 0
            • A
              anoano
              last edited by

              I added network_smtpmail.h, but when I build it
              LINK 2001 error has occurred.
              External symbol "" public: static class maxon :: InterfaceReference maxon :: SmtpErrorInterface :: _ interface "(? _Interface @ SmtpErrorInterface @ maxon @@ 2VInterfaceReference @ 2 @ A)" is unresolved

              How can I solve this?

              1 Reply Last reply Reply Quote 0
              • M
                m_adam
                last edited by m_adam

                All interfaces or functions/classes that are part of the new core are stored in the maxon folder. So you have to write #include "maxon/network_smtpmail.h".

                Moreover, you have to make sure network.framework is included. You can have an overview of each framework here or either you can go on the header file and on the bottom left the framework is written. For your case take a look at network_smtpmail.h.

                I hope it solves your issue. Please let me know.
                Cheers,
                Maxime!

                MAXON SDK Specialist

                Development Blog, MAXON Registered Developer

                1 Reply Last reply Reply Quote 1
                • A
                  anoano
                  last edited by

                  I could write #include "maxon / network_smtpmail.h" and load it successfully.
                  But then I get a message that SmtpErrorInterface and SmtpMailInterface can not be resolved.

                  There was an error when opening network_smtpmail1.hxx and network_smtpmail2.hxx.

                  How can I do this?

                  1 Reply Last reply Reply Quote 0
                  • M
                    mp5gosu
                    last edited by mp5gosu

                    Just a dumb question: Did you include the maxon framework in your projectdefinition and did you run the project tool after that?

                    1 Reply Last reply Reply Quote 2
                    • A
                      anoano
                      last edited by anoano

                      I do it in the following procedure

                      1. Create project file with project_tool

                      2. Add network.framework to frameworks

                      3. Add path in include directory from project properties![alt text]
                        😄 \ sdk \ frameworks \ network.framework \ source
                        😄 \ sdk \ frameworks \ network.framework \ generated \ hxx

                      alt text

                      1 Reply Last reply Reply Quote 0
                      • M
                        m_adam
                        last edited by m_adam

                        Hi @anoano how did you add the network.framework?
                        With the R20 you shouldn't manually create your solution or add anything to it, the project tool will take care of it.
                        The usual way would be:

                        • Add the framework to your projectdefinition.txt located in plugins\YourProjectDir\project\
                          • Add network.framework to the API entry.
                        • (Re-)run the project tool, which will update your solution for visual studio/xcode with the new framework.
                          • This is also valid when you create/remove a file in order to get a synchronized solution for both Windows and Mac OS.)
                        • Open the solution in VS/Xcode and Compile.

                        You can find information about projectdefinition.txt and project tool here.

                        Cheers,
                        Maxime.

                        MAXON SDK Specialist

                        Development Blog, MAXON Registered Developer

                        1 Reply Last reply Reply Quote 1
                        • A
                          anoano
                          last edited by

                          Error did not come out safely.
                          I did not understand how to use projectdefinition.txt.
                          You can proceed with this.
                          Thank you very much.

                          1 Reply Last reply Reply Quote 0
                          • M
                            m_adam
                            last edited by m_adam

                            Hi @anoano

                            I'm wondering if your question has been answered. If so, please mark this thread as solved.

                            Cheers,
                            Maxime.

                            MAXON SDK Specialist

                            Development Blog, MAXON Registered Developer

                            1 Reply Last reply Reply Quote 0
                            • First post
                              Last post