Sending mail by button [closed] - email

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I want to send e-mail after confirmation box. I make a button and push after i should choice yes or no. If NO nothing do. If yes i want to start to SendAnEmail.
Please help me. How can I start the function SendAnEmail?
Thank you.
function SendAnEmail() {
var email = 'my#mail.com'
var subject = 'mySubject';
var body = 'body of mail';
GmailApp.sendEmail(email, subject, body);
}
function test(){
var ui = SpreadsheetApp.getUi();
var ret = ui.alert('Do you want send e-mail?', ui.ButtonSet.YES_NO);
if(ret == ui.Button.YES)
{GmailApp.sendEmail}
}
Thank you

You are almost there
The only thing you need to do is to call function SendAnEmail() when the button Yes is pressed.
So:
function test(){
var ui = SpreadsheetApp.getUi();
var ret = ui.alert('Do you want send e-mail?', ui.ButtonSet.YES_NO);
if(ret == ui.Button.YES){
SendAnEmail()
}
}

Related

How to persist state from a class into a separate SwiftUI view? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
I am having problems persisting a class's state into a SwiftUI struct's view.
I have a class that acts as a controller, defined in one file, and a SwiftUI view that is supposed to change according to properties in that controller.
I've defined these files as such:
ClockController.swift
class ClockController:ObservableObject {
#Binding var isAM:Bool
init(){
self.isAM = false
}
func toggleAMPM(){
self.isAM = !self.isAM
}
}
and TestUI.swift
struct TestUI:View{
#ObservedObject var clockController:ClockController = ClockController()
var body: some View {
Button(action: {
self.clockController.toggleAMPM()
}){
Text("Toggle")
}
Text(self.clockController.isAM ? "AM" : "PM")
}
}
I want the TestUI to change/re-render every time the self.clockController.isAM variable changes (when the toggle button is pressed), which is why I have made ClockController an ObservableObject and added the #Binding keyword to the isAM property. However, I keep getting the following errors with this setup on ClockController's initializer method:
'self' used in property access 'isAM' before all stored properties are initialized and Return from initializer without initializing all stored properties
How can I get my TestUI to bind on ClockController's isAM variable?
all! I've fixed the problem myself. I needed to remove the #Binding keyword from ClockController's isAM property and change it to #Published. That did the trick.
Kudo's to YouTube and this video: https://youtu.be/-yjKAb0Pj60?t=919

Flutter : Voice command to give user weather and date time update [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 1 year ago.
Improve this question
I want to create an application that work on voice command. In this application there is two options when user ask for weather or time update the application get the current weather and give update about weather in voice and the same functionality for time and date. Please help me how I can achieve this in flutter.
You can either use :
https://alan.app/docs/tutorials/flutter/integrating-flutter
or use:
https://pub.dev/packages/speech_to_text
import 'package:speech_to_text/speech_to_text.dart' as stt;
stt.SpeechToText speech = stt.SpeechToText();
bool available = await speech.initialize( onStatus: statusListener, onError: errorListener );
if ( available ) {
speech.listen( onResult: resultListener );
}
else {
print("The user has denied the use of speech recognition.");
}
// some time later...
speech.stop()
Then treat specific words as commands:
void resultListener(SpeechRecognitionResult result) {
++resultListened;
print('Result listener $resultListened');
setState(() {
lastWords = '${result.recognizedWords} - ${result.finalResult}';
});
}

How to get Recent Photo? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Currently i and doing on an Flutter Camera Project. May i know how can i get the recently photo to show on the container like Instagram stories left bottom?
var result = await PhotoManager.requestPermission();
if (result) {
// success
List<AssetPathEntity> list = await PhotoManager.getAssetPathList(type: RequestType.image);
final assetList = await list[0].getAssetListRange(start: 0, end: 1);
filename = await assetList[0].file;
setState(() {
});
} else {
// fail
/// if result is fail, you can call `PhotoManager.openSetting();` to open android/ios applicaton's setting to get permission
}
This works for me for getting the most recent image from the device as a thumbnail according to the plugin used from the website given by you.

Ionic testing - asynchronous look for a change in ionViewDidLoad [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
I have troubles trying to test the value of a variable that change inside the ionViewDidLoad method
welcomepage.ts
#Component({...})
export class WelcomePage {
test: number = 0;
constructor(){}
ionViewDidLoad(){
this.test = 1;
}
}
welcomepage.spec.ts
it('test should equal be equal to 1', () => {
fixture.detectChanges();
expect(component.test).toBe(1)
});
But this test is not succeeding. If I do the change inside the constructor function (this.test = 1) then it is working.
======== UPDATE ========
It seems that it is a problem with ionViewDidLoad function triggered by ionic, it is working as usual by running ionic but not in the test.
It appears that ionic life-cycle events (ionViewDidEnter, ionViewDidLoad, ...) are not called during testing, by calling it manually it works :
it('test should equal be equal to 1', () => {
component.ionViewDidLoad();
fixture.detectChanges();
expect(component.test).toBe(1)
});
But then how are we sure that ionic really call ionViewDidLoad ?
Your variable is not setting because you have done it in wrong way. Your variable name is test and you are setting value in variable type which is number. Please see the following snippet, hope it helps.
#Component({...})
export class WelcomePage {
test: number = 0;
constructor(){}
ionViewDidLoad(){
this.test = 1;
}
}

How to hide google adsence advert in a page for certain countries? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am a blogger and place google ads in my blog. I do not want to these ads to show up in certain countries is there any additional code I can use in my page that can help me achieve this.
For an example i do not want advert to show in Germany. Any Advise?
You can use API from http://www.geoplugin.net/
Eg. in PHP
$xml = simplexml_load_file("http://www.geoplugin.net/xml.gp?ip=".getRealIpAddr());
$country = $xml->geoplugin_countryName ;
if($country != "Germany")
{?>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Horizontal Big Banner -->
<ins class="adsbygoogle"
style="display:inline-block;width:970px;height:250px"
data-ad-client="ca-pub-XXXXXXXXXXX"
data-ad-slot="XXXXXXXX"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
<?php
}
//For getting IP Address
function getRealIpAddr()
{
if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet
{
$ip=$_SERVER['HTTP_CLIENT_IP'];
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy
{
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}
else
{
$ip=$_SERVER['REMOTE_ADDR'];
}
return $ip;
}