Send details to email on click of a button - android-studio

I am developing an android app and i have a few edit texts and a submit button.
On click of the submit button all the fields in the edit texts entered by the user should be sent to a particular email id.
Could anyone please suggest me how it can be done?

String s = editText.getText().toString();
in button's onClickListner() method use this
Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:" + email));
emailIntent.setType("text/plain");
emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(Intent.EXTRA_TEXT, s);
//emailIntent.putExtra(Intent.EXTRA_HTML_TEXT, body); //If you are using HTML in your body text
startActivity(Intent.createChooser(emailIntent, "Send Email via"));
Already answered Here
As you are working with multiple editTexts you can do this,
String s = (editText1.getText().toString() + "\n" + editText2.getText().toString() + "\n"+editText3.getText().toString() + "\n" + editText4.getText().toString() + "\n" + editText5.getText().toString() + "\n" + editText6.getText().toString() + "\n");
and then use same snippet as above.
If you want to know how send email without prior user interaction then see this answer
see this code snippet here also : https://github.com/enrichman/androidmail
There is also an API available named mandrillapp:
Read this blog for full code : https://www.mindstick.com/Articles/1673/sending-mail-without-user-interaction-in-android

Related

Button in Lotus Notes that automatically forwards en email with attachment

I'm trying to make a button in IBM Notes that automatically forwards emails with attachments to a specific address.
I have looked at 2 previous examples on this website but none of them are working for me and I get the mail forwarded to myself.
Can anyone help?
The 2 codes I've tried are:
_From := #Text(From);
#Command([MailForward]);
#Command([EditNextField]);
#Command([EditInsertText]; _From);
#Command([EditGotoField]; "Body");
#Command([EditInsertText]; "Your text" + #NewLine + "goes here...")
and
FIELD SendTo:= "person#mail.com" ;
#Command( [MailForwardAsAttachment] )
The IBM Notes version I'm using is # 9.
Thank you
Use the first example and change it to:
#Command([MailForward]);
#Command([EditInsertText]; "person#mail.com");
#Command([EditGotoField]; "Body");
#Command([EditInsertText]; "Your text" + #NewLine + "goes here...")
Replace the email address in second code line with your specific address and adapt the remaining lines too.

Access field in a column in a Lotus Notes view

In Lotus Notes, I have view which has got a column say PolicyNum. Requirement is while double clicking on the document to open, which will open the attachment in the form in the view, it has to be validated against a computed field say SecureDoc which contains either Yes or No.
For client version this is easy as in the queryopen in the form it is validated and exited if the condition doesn't meet with proper messagebox.
But for the web version the column is appeared as a link and the messagebox has to appeared as alertbox in JS. In the PolicyNum column I have tried to use #GetField("SecureDoc") which will get the value of the field for that particular document.
Column Formula:
furl:="javascript:alert('Document not available');return false";
OpenDisp:="[" + PolicyNumber + "]";
secDoc:=#GetField("SecureDoc");
#If(att = "" ; OpenDoc ;secDoc="Yes";OpenDisp;OpenAttach)
Here OpenDoc and OpenAttach are different string which will open the document and attachment respectively depending on the att, which checks for the attachment.#GetField("SecureDoc") return "". So if I write #If(att = "" ; OpenDoc ;secDoc="";OpenDisp;OpenAttach) it is showing the alert box and is working fine.
So the requirement is to get the handle of the field value for the particular doc which is to be clicked on web and check for the condition.
Also webqueryopen is not working..
Note: On opening the document it is opening the attachment in the form and not the form itself.
Column Value :
view := "0";
att := #AttachmentNames;
WebName := #WebDbName ;
url := "'/" + WebName + "/" + view + "/" + #Text(#DocumentUniqueID) + "/$File/" + att + "?OpenElement'";
url := "window.open(" + url + ");" ;
url := #Implode(url; ";");
url := "javascript:" + url + " return false;\" href=\"javascript:void(0);";
furl:="javascript:alert('Document not available');return false";
OpenAttach := "[<TABLE><TR><TD NOWRAP><a target=_blank onClick=\"" + url + "\">" + PolicyNumber + "</a></TD></TR></TABLE>]";
OpenDoc := "[<TABLE><TR><TD NOWRAP>" + PolicyNumber + "</TD></TR></TABLE>]";
OpenDisp:="[<TABLE><TR><TD NOWRAP><a target=_blank onClick=\"" + furl + "\">" + PolicyNumber + "</a></TD></TR></TABLE>]";
secDoc:=#GetField("prevSecDoc");
#If(att = "" ; OpenDoc ;secDoc="Yes";OpenDisp;OpenAttach)
I have tried with both #If(att = "" ; OpenDoc ;secDoc="Yes";OpenDisp;OpenAttach) and #If(att = "" ; OpenDoc ;prevSecDoc="Yes";OpenDisp;OpenAttach) but it is not getting the value as "Yes". Though when I open the document through URL giving the docid it ha the value as "Yes"
Quick back to basics : a document is a record in a database, a form is, well, a form, which determines how data are input by the user and controls display.
Allow me to rephrase your question. If the document contains a field named "SecureDoc", and if said field holds the value "NO", then a click on the link must not open the document and present the user with a JavaScript alert.
One could question why display the document in the view in the first place, and then why have a link with no other effect than telling it has no effect.
OK, not my place to question the requirements.
My suggestion would be that the content of the column displayed for web access be a computed hyperlink :
href := #If( SecureDoc = "NO";
"javascript:alert('nope')";
"normal url for opening the doc"
);
"" + "the title of the doc or whatever" + ""

How to add two Signer using Custom Button Logic in Salesforce

Below i have coded the Custom Button in Javascript to add two signer in Docusign Envelope.
var RROS='1';
var CRL='Email~{!Case.Hidden_Merchant_Email__c};LastName~{!Merchant__c.Name};Role~Signer 1;RoutingOrder~1;Email~{!Account.PersonEmail};LastName~{!Account.LastName};Role~Signer 2;RoutingOrder~2,LoadDefaultContacts~1';
var CCRM='Signer 1~Merchant;Signer 2~Account Holder';
var CCTM='Signer 1~Signer;Signer 2~Signer';
window.location.href = "/apex/dsfs__DocuSign_CreateEnvelope?DSEID=0&SourceID={!Case.Id}&CRL="+CRL+"&RROS="+RROS+"&CCRM="+CCRM+"&CCTM="+CCTM;
But here only signer is added in Docusign Envelope. I need to add two Signer in Envelope. Can anyone please provide the correct script if i made a mistake in the given code?. Thanks in advance.
Yes, you can send to more than one recipient. Even better, not all of the recipients need to be signers. Eg, you can send to some people to get a copy of the document after it's been signed, rather than sign. There are other options too, including Sign in person signers, etc.
Anyhow, multiple recipients are sent via the CRL query parameter, separated with commas. This documented on page 67 of the Admin Guide
Here's my version of your code (untested).
var RROS='1',
CRL='Email~{!Case.Hidden_Merchant_Email__c};' +
'LastName~{!Merchant__c.Name};' +
'Role~Signer 1;' +
'RoutingOrder~1,' + // end of signer 1
'Email~{!Account.PersonEmail};' +
'LastName~{!Account.LastName};' +
'Role~Signer 2;' +
'RoutingOrder~2,' + // end of signer 2
'LoadDefaultContacts~1',
CCRM='Signer 1~Merchant;Signer 2~Account Holder',
CCTM='Signer 1~Signer;Signer 2~Signer',
qparams = 'DSEID=0&' +
'SourceID={!Case.Id}&' +
'CRL="' + CRL + '"&' +
'RROS="' + RROS + '"&' +
'CCRM="' + CCRM + '"&' +
'CCTM="' + CCTM + '"';
window.location.href = "/apex/dsfs__DocuSign_CreateEnvelope?" + qparams;

Create an iconNote Document in a new database

This is a more explicite extension on my previous question.
From an button on an XPage I create a new database
targetDB = dir.createDatabase(fileName);
I then copy a bunch of stuff into the targetDB from the sourceDB. I then want to set the launch properties in the targetDB which is where the problem comes.
I know that I can get the iconNote = targetDB.getDocumentByID("FFFF0010") except there is no iconDoc in the target. Does anyone have a way to create this doc with the specific NoteID?
I tried copying the iconNote document from the sourceDB to the targetDB but that does not work. Changes the UNID and noteID. Can't find any database method to create an icon Note.
Found lots of stuff on how to change the settings in the iconNote, but nothing on how to create one if there is not one in the database.
Thanks to Jesse I took his code and changed it to SSJS and it works fine.
var dir:NotesDbDirectory = session.getDbDirectory("Development");
var newDB:NotesDatabase = dir.createDatabase("XPages/install/created.nsf");
var importer:NotesDxlImporter = session.createDxlImporter();
importer.setDesignImportOption(6);
var dxl:String = "<?xml version='1.0'?>\n" +
"<note default='true' class='icon'>\n" +
" <item name='$TITLE'>\n" +
" <text>Test Title</text>\n" +
" </item>\n" +
" <item name='$Flags'>\n" +
" <text>J7NZq?!</text>\n" +
" </item>\n" +
"</note>\n";
importer.importDxl(dxl, newDB);
var iconNote = newDB.getDocumentByID("FFFF0010");
iconNote.replaceItemValue("$DefaultXPage", "xpWFSDemo.xsp");
iconNote.replaceItemValue("$DefaultClientXPage", "xpWFSDemo.xsp");
iconNote.save();
dBar.info(iconNote.getItemValueString("$Flags"));
Something like this oughta do it:
DbDirectory dir = session.getDbDirectory(null);
Database newDB = dir.createDatabase("tests/created.nsf");
DxlImporter importer = session.createDxlImporter();
importer.setDesignImportOption(DxlImporter.DXLIMPORTOPTION_REPLACE_ELSE_CREATE);
String dxl = "<?xml version='1.0'?>\n" +
"<note default='true' class='icon'>\n" +
" <item name='$TITLE'>\n" +
" <text>Some DB Title</text>\n" +
" </item>\n" +
" <item name='$Flags'>\n" +
" <text>J7NZq?!</text>\n" +
" </item>\n" +
"</note>\n";
importer.importDxl(dxl, newDB);
That's with the two "open XPage" options set already - you could also include the two XPage name items the same way, and it may be a good idea to export the icon note from an existing DB (database.getDocumentByID("FFFF0010").generateXML()) and paste in the actual icon item as well, since this DXL will result in an icon-less database. Nonetheless, it seems to work in my testing as a basis.
And after that point, you'll be able to fetch the icon note using the usual "FFFF0010" pseudo-ID and replace item values the same way I mentioned before.

Gmail - Import to contacts link

When you go to Contacts >> More >> vCard format >> Export - this will create a contact file.
If you then compose a new message, attach that .vcf file, send to a Gmail address - Gmail will display a nice "Import to contacts" shortcut link to the recipient.
When you re-create the .vcf file in GAS in the same format as the exported file and send it as an attachment with GmailApp, Gmail does not show the "Import to contacts". It just shows "View".
However, if you click Download on the file created with GAS then attach and send in a new message composed manually, Gmail will show the Import link.
Is there anything Apps Script can do to ensure the "Import to contacts" link shows up when using GmailApp to send a vCard file as an attachment or is this really more of a Gmail issue?
var layout = 'BEGIN:VCARD' + '\n' +
'VERSION:3.0' + '\n' +
'FN: Forrest Gump' + '\n' +
'N:Gump;Forrest;;;' + '\n' +
'EMAIL;TYPE=INTERNET:forrestgump#example.com' + '\n' +
'END:VCARD' + '\n';
var vCard = [{fileName:"new contacts.vcf", content:layout}];
GmailApp.sendEmail("example#gmail.com", "Subject", "Body...", {attachments: vCard});
It's because you sent it as plain text. If you want Gmail to recognize it as vCard. You need to send it as octet-stream.
To fix this just put mimeType:"application/octet-stream" to your attach file description
e.g.
var vCard = [{fileName:"new contacts.vcf", content:layout, mimeType:"application/octet-stream"}];

Resources