create a button that emails the google sheet - email

In a google sheet that I've created, I have a place where I can put in an email address (in my sheet, it is actually located at cell I6. What I'm needing to do is create a script that will pull this email address out of I6 and then email the sheet to that email. I don't want to email every sheet, just that page that has the button I've created.
The main script I have thus far is:
function sendemail() {
MailApp.sendEmail("email address", "subject", "body");
}
Where it says "email address", I want it to pull the contents of cell I6. What is the coding to do this?
Any help is greatly appreciated.
Thanks,
Cliff

Since UI Service is deprecated, the only option is to assign a script to an image or drawing.
I've followed this tutorial - Google Spreadsheet Button to Run Scripts
Here is the code snippet:
function highFive(){
Browser.msgBox("High Five!");
}
Once I click the image this will happen:
Also in the tutorial, there is a snippet regarding sending an email with the button:
function email(){
var rng = SpreadsheetApp.getActiveSheet().getActiveRange()
var email = rng.getValues()[0];
GmailApp.sendEmail(email[0], email[1], email[2]);
}
Hope this helps.

Related

How to show related email on popup composeMailData - Vtiger

I have a custom module, in this module there is a field related to the account, then I create an email send button on the detail page, how can when the compose mail popup is displayed, the email of this account is added automatically.
EditView
DetailView (compose mail popup)
You need to put that logic in your view controller. Take vtigercrm/modules/Vtiger/views/ComposeEmail.php as an example and create vtigercrm/modules/YourCustomModule/views/ComposeEmail.php
You need to do something similar to this when processing the request:
$accountId = $request->get('accountid');
$account = Vtiger_Record_Model::getInstanceById($accountId);
$viewer = $this->getViewer($request);
$viewer->assign('TO', $account->get('email'));

Adding attachment to Outlook email with VSTO

I'm trying to develop a custom attach file button that will show on the ribbon of a new, blank email. ( I would like to insert the button in the highlighted section)
This article from MSDN shows how to attach a file and create the email, which is useful but not exactly what I'm after. Is there any documentation on adding attachments to emails which are already open?
Application.ActiveInspector.CurrentItem.Attachments.Add
I was in the OfficeRibbon context so I ended up using the following code:
var item = this.Context as Outlook.Inspector;
var mailItem = item.CurrentItem as Outlook.MailItem;
mailItem.Attachments.Add(attachment.Location, Outlook.OlAttachmentType.olByValue, 1, attachment.FileName);

Sending email in Xamarin Forms project

I'm trying to use the Xamarin.Plugins.Messaging NuGet package to send emails from within my Xamrin Forms shared project but keep running into Warning: Attempt to present X on Y whose view is not in the window hierarchy! and nothing appears.
Is there something else that I have to set up?
private void SendEmail()
{
var emailMessagner = CrossMessaging.Current.EmailMessenger;
if (emailMessagner.CanSendEmail)
{
Console.WriteLine("Can send mail");
var email = new EmailMessageBuilder()
.To("emailaddress#gmail.com")
.Subject("Setting subject")
.Body("Setting email body")
.WithAttachment(_filePath, "text/html")
.Build();
emailMessagner.SendEmail(email);
}
else
{
Console.WriteLine("Cant send mail");
}
}
It works on android (other than getting Permission denied for attachment), but I get window not in hierarchy error for iOS. I could write my own email sender that would make sure it's viewController is in the window hierarchy but I assumed this plugin handled that.
I was having the same issue with my Xamarin Forms app. I was calling SendEmail() from a ContentPage which I loaded with PushModalAsync() in a PCL project. As far as I can tell, this doesn't work in any way, shape or form from a modal form.
My work-around was to add a public static Queue property to the calling form (the main form of my app in this case) and when I needed to send an email, I added it to the queue. Then I overrode OnAppearing() on my main page and looped through all of the emails in the queue whenever the main form came back into view. I put a note on my modal form telling the user that the email would be sent when the modal form was closed. Not perfect, but it works. If you can find a way around this for modal forms, that would be fantastic!
Mike

JScript setText() in email and password not being read

Hello StackOverflow -
My issue is a strange one and hopefully someone has seen something like it before.
I'm using TestComplete to do front-end functional testing with a REST API.
We have a Login button that drops a modal to enter email and password.
My script:
function modalCheck()
{
var emailBox, mainPage, unexpWnd;
//Browsers.Item(btFirefox).Run("http://[redacted]");
var mainPage = Sys.Browser("firefox").Page("http://[redacted]/");
var loginModalButton = Sys.Browser("firefox").Page("http://[redacted]/").Panel(0).Header(0).Panel(0).Nav(0).Panel(0).Panel(1).Button("login");
//click login button to drop modal
if(loginModalButton.Exists)
{
loginModalButton.Click();
Log.Message("This button exists and I clicked it.");
}
//modal now visible = assign text and click login submit button
var emailBox = Sys.Browser("firefox").Page("http://[redacted]/").Panel(4).Panel(0).Panel(0).Panel(1).Form(0).Panel(0).Panel(0).Panel(0).Panel(0).Textbox("email");
var passwordBox = Sys.Browser("firefox").Page("http://[redacted]/").Panel(4).Panel(0).Panel(0).Panel(1).Form(0).Panel(0).Panel(0).Panel(0).Panel(0).PasswordBox("password");
var loginSubmitButton = Sys.Browser("firefox").Page("http://[redacted]/").Panel(4).Panel(0).Panel(0).Panel(1).Form(0).Panel(1).Panel(0).Panel(0).SubmitButton("login_submit");
emailBox.setText("[redacted]");
passwordBox.setText("[redacted]");
Delay(5000);
loginSubmitButton.Click();
//need to logout - now the button will show "Logout" instead of "Sign Up"
var logoutButton = Sys.Browser("firefox").Page("http://[redacted]/").Panel(0).Header(0).Panel(0).Nav(0).Panel(0).Panel(1).Button("logout");
if(logoutButton.Exists)
{
logoutButton.Click();
Log.Message("This button exists and I clicked it.");
}
}
I can drop the modal, enter my email and password, and click the login button successfully with this script. The problem is - my credentials aren't recognized and/or are flagged as incorrect if they're entered via my script or if the browser autofills them. They work if entered manually (so I know they're correct and I'm not locked out).
As a tester, this is pretty black-box for me. I can pass along some HTML but I'm not involved in the creation. I can also ask the front-end guys more specific questions if it would help solve my issue.
What does it look like my problem is?!
Use the Keys method instead of SetText. The later puts the text directly to the control and this does not fire the required events.
emailBox.Keys("[redacted]");
passwordBox.Keys("[redacted]");

MFMailComposeViewController and cancelling "save" action sheet?

i am using MFMailComposeViewController inside my iphone app. I notice that if i enter any text in the body and then press the cancel button, i am prompted with an action sheet with an option to save/don't save the unsent message. I have two questions:
can I programmatically prevent the "save/don't save action sheet from appearing? MFMailComposeViewControllerDelegate doesn't appear to have anything along those lines
if i do save, where is the mail saved to? i looked in my mail accounts and didn't see anything saved in any of the "draft" folders.
No, you can't avoid the action sheet appearing. It's been added in iOS 4.x to, precisely, avoid tapping on the "Cancel" button inadvertently when writing a long email, which I think it's a good idea.
It is saved in "Drafts" folder of the account used to compose the e-mail (normally, your "default account" as it is registered in the Settings of your device). I've just tried using a couple of apps and it works.