Solved About PopupEditText and SendMail

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.

Hi @anoano, first of all, I would like to point you to our Q&A functionality please use it. :wink:
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!

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?

You can now use it after adding a path.

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?

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!

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?

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

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]
    C: \ sdk \ frameworks \ network.framework \ source
    C: \ sdk \ frameworks \ network.framework \ generated \ hxx

alt text

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.

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

Hi @anoano

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

Cheers,
Maxime.