A button to send email from "Detail" screen

hi guys, i have a grid that has “Detail” enabled. I need a button to send the details information (including BLOB field - image) to an email address specifed by end user. hence, i think we will need a new form application to prepare the email to field? the button to cpature the information and prepare them so the end user adds the email he wants to send to then hit send?

this is my first time facing email sending thing, i guessed it is easier becase i found “send simple email” and “send email with attachment” in the codes section of the event, but obviously is harder than expected

anybody done that before?

Hi itsme3,

in my eyes the detail of the grid normally is useless … (!personal opinion). As long, you have to enter an email adress, I think the best solution is to open a small form or control app to enter that adress. Within the init event you can load each data you want …
The “send email with attachment” makes it very simple to send the mail. Is working for me with single & multi mailing app.

BR

Eric

Perfect, that is what i need, could you please tell more more details about which event and how to load the fields?

the reason why i want the “Details”, is that in grid i don’t show all fields, but in details i show them all. so if any other way that can send a complete row, even from the grid itself without going into the details, is also fine… i just want to make the user to write the email address before sending the complete row values (along with one BLOB image)

appreciated your time in explaining this, i think it is a value for everyone as i did search in the forum but couldn’t find such thing…

Mike

OK, just a short description, but should be basics …

  1. create a form of the table you want to use.
  2. from the grid generate an application Link to the form of step 1.

what do we have, a grid, where you can choose a column from to display in a form. There you can choose, to edit, to hide or to label the data fields.

  1. in the forms fields make a new text-data field to have the adress to mail to. If you want, you can also create a subject data field.
  2. go to the forms buttons. create a button send as a php type and select within the code area the sendmail with attachment code example.
  3. exchange the variable fields of the example with your mail data fields and generate a message text out of your form-fields.
  4. if you like, you can close the form at the end of the form button. I normally use a short java close for that job.

BR

Eric

hi again Eric, and thanks for your tutorial,
I did exactly what you instructed, problem is i already have one application link that is to edit the records of the grid, if clicked a line it will open the edit form to update the values in that record… couldn’t make another application link… i think that is why i was thinking about the details page, if we can make a button there to send the the displayed data then it will be great because in my case all the fields are displayed in the detail page anyway… or any other idea will be appreciated, how about the grid sometimes i see it shows a little tick mark in each line, don’t know if that can be used to select a line and create a button to send those values to a form to send them by email? i have no idea even how to start :slight_smile:

OK, two possiblities:

  1. Do not choose application link, but field link, which will set a link to a field to open the other form.
  2. Or may be more elegant, why don’t you create a send button in the Edit-Form???

BR

Eric

hmmmm good idea, how to add that button? I was concerned about the edit form title says “Edit Record” but it is a good idea, so how to create this button? there is no mailto or subject here!

Create a new field on grid,with an image as content for example,an make a link for this field.

yes but i want those to go by email after writing the mailto/subject for the record, also there are 2 files 1 BLOB image file and 1 image file file name i want them to go along with the email :slight_smile:

But you can call a blank application where you pass the master Id field, and from there retrieve data you need and send email

that is above my experience Giu, don’t know how to do that :frowning: EricB is trying to walk me through easier solution

Mhmmm, in the edit-form, there should be a section button on the left side. Create a “send”-button with php-code section and put the example send mail with attachment code in there. Make the changes and that should it be …

BR

Eric

thank you EricB,

I did that, put the code in the php button and added all my fields in the Message variables with </ br> between them but it keep producing this error when trying to send the form…

Fatal error: Uncaught exception 'Swift_RfcComplianceException' with message 'Address in mailbox given [$this->mailto] does not comply with RFC 2822, 3.6.2.' in E:\sc8\project5\_lib\prod	hird\swift\classes\Swift\Mime\Headers\MailboxHeader.php:308 Stack trace: #0 E:\sc8\project5\_lib\prod	hird\swift\classes\Swift\Mime\Headers\MailboxHeader.php(238): Swift_Mime_Headers_MailboxHeader->_assertValidAddress('$this->mailto') #1 E:\sc8\project5\_lib\prod	hird\swift\classes\Swift\Mime\Headers\MailboxHeader.php(96): Swift_Mime_Headers_MailboxHeader->normalizeMailboxes(Array) #2 E:\sc8\project5\_lib\prod	hird\swift\classes\Swift\Mime\Headers\MailboxHeader.php(60): Swift_Mime_Headers_MailboxHeader->setNameAddresses(Array) #3 E:\sc8\project5\_lib\prod	hird\swift\classes\Swift\Mime\SimpleHeaderFactory.php(60): Swift_Mime_Headers_MailboxHeader->setFieldBodyModel(Array) #4 E:\sc8\project5\_lib\prod	hird\swift\classes\Swift\Mime\SimpleHeaderSet.php(75): Swift_Mime_SimpleHeaderFactory->createMailboxHeader('To', Array) #5 E:\sc8\project5\_lib\prod	hird\swift\classes\Swift\Mime\SimpleMessage.php(306): Swift_Mime_SimpleHeaderSet->addMailboxHeader('To', Array) #6 E:\sc8\project5\_lib\prod	hird\swift\classes\Swift\Mime\SimpleMessage.php(282): Swift_Mime_SimpleMessage->setTo(Array) #7 E:\sc8\project5\form_edit\form_edit_apl.php(1647): Swift_Mime_SimpleMessage->addTo('$this->mailto', '') #8 E:\sc8\project5\form_edit\form_edit_apl.php(1053): epts_email_apl->sc_btn_sc_btn_0() #9 E:\sc8\project5\form__edit\form_edit_apl.php(1144): form_edit_apl->ini_controle() #10
E:\sc8\project5\form_edit\index.php(1556): form_edit_apl->controle() #11 {main} thrown in
E:\sc8\project5\_lib\prod	hird\swift\classes\Swift\Mime\Headers\MailboxHeader.php on line 308

i have mail server installed on the same machine, and it is working fine, but i configured the mail values to be sent like “localhost” because i want to use the phpfunction() to send, not the smtp, is there anything else i must do?

one more thing, hence, if used this button, the mailto field can be left without filling! i put it as required, but the button “send” doesn’t force the user to fill the mailto field! also is not practicle what you think?

Hi itsme3,

first of all, it seems to be something wrong with the sending of the attachment. I have the same error module (swift), when I first tried a sending mail using V8. I am investigating that at the moment, cause I have a sending mail with attachment in the same application working, without error. Was written during V7. To come a little bit closer to the working point, you can test it first without attachment. I am nearly sure that will work. Otherwise, there are some more problems …

The other problem with the button, I would suggest to switch off the button during the init event. Create an axaj-event on the mailto-field (on-change), check in the php code if it is emtpy, if not, switch on, otherwise switch off the sending button. Second switch-off, because someone can enter and delete the adress some time later …

BR

Eric

P.S.:
The error in my app was a stupid wrong filename of the attachment. So, please check the same on your app. Is the filename correct? Is the enviroment up to date? …

Seems logic, will try that… also found an exmple for the same using control app in the example database that comes with SC, will try it as well

regarding the attachment, should i add only the field name like this {fieldname} for the image (database) and the image file name should be like this upload/{fieldname} ?? i have the upload folder is where the file is located in the storage of the image… is this correct?

thanks for your time dude EricB

Mike

Hi Mike,

for the attachment you will need the whole path plus filename. That was the mistake I made ^^ Forgot the subdirectory, where I stored the files to.

BR

Eric

hmmm do you mean like www.domainname.com/scaproject/scapplication/storagefolder/{fieldname} ? or just storagefolder/{fieldname}

Addresses are taken relative to the root. But why not just experiment. One test and you know it all?

hi Albert, because this sc8 drives me crazy, many things are not functional as I want really feeling bad and wanna move this project to sc7, it is correct i need this email thing but i have to finish other tasks too :frowning: and stuck in group by dilemma now, will try them all because the mail function needs to deploy to a server to test… thats why i am putting as the last thing before the security apply then deploy and test

Just deploy to another server directory to test. I can say, that the V8 mail function is working.

Btw, both should work, relative and inet path format.