Showing posts with label Email. Show all posts
Showing posts with label Email. Show all posts

Friday, June 25, 2021

GMail Forward Email for all items in label

/*
Main
https://stackoverflow.com/questions/56023037/forward-email-message-with-mailapp-instead-of-gmailapp
*/
function forwardForever() {

  Logger.log('forwardForever2() START ');
  var labelName = "Trash"

  var threads = GmailApp.search("in:trash label:" + labelName);
  Logger.log('forwardForever2() threads.length ' + threads.length);
  for (var i = 0; i < threads.length; i++) { 
   Logger.log('forwardForever2() forward id ' +  threads[i].getId());
     try
     {
         // try this just in case
        //Gmail.Users.Messages.remove('me', threads[i].getId());
        var firstThread = threads[i];
        var message = firstThread.getMessages()[0];
         Logger.log('forwardForever2() START forward ' + message.getSubject());
        
        message.forward("1@yahoo.com");

        Logger.log('forwardForever2() DONE forward ' + message.getSubject());
        
     }
     catch(e){
        Logger.log('forwardForever2() ERROR id ' +  threads[i].getId());
        Logger.log(e);
     }
     Logger.log('forwardForever2() NEXT...');
    
  }
}

Friday, September 11, 2020

Google API App Errors: Less Secure App Access setting

If you have an app that interfaces with Google or use a 3rd party API integration, for example sendEmail smtp utility, you may start receiving an error in scripts that worked previously,. The error may look like:

 

C:\Temp\Tools\sendEmail-v156>Synch.OneWay.MyDocs.GDrive.Zip.Email
Sep 11 15:06:19 doylejsurface2 sendEmail[16576]: ERROR => ERROR => SMTP-AUTH: Authentication to smtp.gmail.com:587 failed.

To resolve enabel the less secure app access toggle in your Google profile:

Update Less secure app access in google

normally the setting is located here

Monday, July 29, 2019

Search using Date Range in Windows and GMail

1. Windows

- Date between 3/26 and 3/28

datemodified:‎3/‎26/‎2019 .. ‎3/‎28/‎2019

- Other Date Examples,

modified:2/1/2016 .. 2/20/2016
Note the two periods between the dates, this tells the search engine to use it as a range. You could also use “Datecreated:” or just “date:” instead of “modified:” if you wanted to.

- Advanced Examples Here

2. Gmail:

   

Before/After Date


     before:2018/9/1
     after:2018/9/1 before:2018/11/18
    

Before/After Relative Date (instead of specific date)


     newer_than:2d
     older_than:30d

Search multiple labels!


         label:(sent OR inbox)
         label:(sent OR inbox) Indeed
         label:(awork-jobs OR awork-jobs-jobsites) Indeed
         label:(awork-jobs OR awork-jobs-jobsites | awork-jobs-melbourne) older_than:30d
         label:(label:awork-jobs-remote) older_than:30d

Sunday, July 28, 2019

Setup Office365 Email account in Outlook 2010 or 2013


Quick Settings
Incoming Settings:
  • outlook.office365.com
  • port 995
  • SSL applied/ticked

Outgoing Server Settings:
  • smtp.office365.com
  • port 587
  • SMTP authentication applied/ticked
  • TLS applied/ticked
  • Authentication - password
Step by Step Instructions
  1. Open Outlook 2010.
  2. Select the File tab.
  3. Click on + Add Account.
  4. Complete the following Fields:
    • Your Name
    • Email Address
    • Password
    • Re-type your password 
  5. Click Next, a window will appear advising you that it is configuring the network settings.  An Error may be displayed asking you to search unencrypted.
  6. Click Next. If this fails to connect and you receive an error message tick the  Manually configure server settings box and click Next.
  7. Select Internet E-mail and click Next.
    • Select POP3 form the Account Drop Down.
    • In the 'Incoming mail server' field type outlook.office365.com
    • In the 'Outgoing mail server' field type smtp.office365.com
    • In the Username field type in your full email address
    • In the Password field enter your email password
  8. Click on More Settings.
  9. Click on the Outgoing Server tab.
  10. Tick My outgoing server requires authentication.
  11. Ensure the radio button next to Use the same settings as my incoming server is selected and click Ok button.





  12. Click on the Advanced tab.
  13. In the Incoming server field enter 995.
  14. Tick This server requires an encrypted connection (SSL).
  15. In the Outgoing server field enter 587.
  16. From the drop down menu next to Use the following type of encrypted connection select TLS.
                                    
  1. Click OK.
  2. Click on Test Account settings and a results window will be displayed.
  3. Click Close to continue. A confirmation screen will be displayed.
  4. Click Finish. A list of email accounts will then be displayed.
                                
Click Close.
  You should now be able to send and receive emails.


Office 365 Outlook Find POP, IMAP and SMTP Servers

1. go to portal.office.com

2. Open Outlook app

3. Gear Icon | Your app settings | Mail |

4. Expand Tree: Mail | Accounts | POP and IMAP

Normally servers are:

POP setting
Server name: outlook.office365.com
Port: 995
Encryption method: TLS

IMAP setting
Server name: outlook.office365.com
Port: 993
Encryption method: TLS

SMTP setting
Server name: smtp.office365.com
Port: 587
Encryption method: STARTTLS


For more info see : here

Tuesday, May 7, 2019

GMail sample filter using OR and AND logical operators

I had a need to filter all emails coming from autotrader or cargurus or autolist and I wanted the emals be placed moved into a label of my choosing. To achieve this we can use the following Search. We can then save this Search as a Filter/ The Filter then will have an action to move emails that match this criteria to a label.

  • - To use OR operator: simply type OR or a | (pipe char) blank space

subject:(Best OR Vimeo)

subject:(Best | Vimeo)

  • - To use AND operator: type AND

subject:(Now AND Vimeo)

So lets build the search,

1) Get your search right:

from:(*autolist.com | *autotrader.com | *cargurus.com)

2) Now build the filter, here is a screen recording of how I did this

Finished Example See here

Here are some great links with examples:

https://emailanalytics.com/25-gmail-search-operators-that-will-make-you-a-gmail-pro/

https://digitalinspiration.com/gmail-search-4355

https://webapps.stackexchange.com/questions/92004/how-to-use-or-operator-in-gmail

Sunday, November 25, 2018

Gmail: Using Google Apps Script to Auto Delete Gmail Trash on a schedule! (or anything else for that matter)


1) Create Script

2) test

3) Schedule


Some really cool stuff we can do using Google Developers Dashboard, some references here:

https://gist.github.com/balupton/9800939

and

https://www.mikecr.it/ramblings/marking-gmail-read-with-apps-script/


for my case I need to purge the Trash every Sunday, to do this:

Summary as follows:

1) Create a script to clean Trash label (folder)

function deleteForever() {

  Logger.log('START ');
   var labelName = "Trash"

  var threads = GmailApp.search("in:trash label:" + labelName);
   for (var i = 0; i < threads.length; i++) {
    Logger.log('Delete id ' +  threads[i].getId());
      try {
         Gmail.Users.Messages.remove('me', threads[i].getId());
      }
      catch(e){}
      Logger.log('DONE Delete id ' +  threads[i].getId());
   }
}


2) To enable advanced services for this script, locate Resources on the menu, and select Advanced Google services...

3) Enable Gmail API on the list.

4) Before selecting OK, click on the Google Developers Dashboard link. Search for gmail, and enable

5) Schedule via a trigger:


FYI:

If new to G Scripting, use logging per this spec


Basic logging

A basic approach to logging in Apps Script is to use the built-in Logger. Logs created this way can be viewed by selecting View > Logs in the script editor. These logs are intended for simple checks during development and debugging, and do not persist very long.

For example, consider this function:

function emailDataRow(rowNumber, email) {
  Logger.log('Emailing data row ' + rowNumber + ' to ' + email);
  var sheet = SpreadsheetApp.getActiveSheet();
  var data = sheet.getDataRange().getValues();
  var rowData = data[rowNumber-1].join(" ");
  Logger.log('Row ' + rowNumber + ' data: ' + rowData);
  MailApp.sendEmail(email,
                    'Data in row ' + rowNumber,
                    rowData);
}

When this script is run with inputs "2" and "john@example.com" the following logs are written:

[16-09-12 13:50:42:193 PDT] Emailing data row 2 to john@example.com
[16-09-12 13:50:42:271 PDT] Row 2 data: Cost 103.24

The Logger.log() method expects a string or other JavaScript object. The logs can only hold a limited amount of data, so avoid logging large amounts of text.

Monday, October 15, 2018

GMail Search & Filters : Search Syntax + some filter examples to auto label emails

References:

Gmail Filters : Exhaustive Syntax Documentation

Some advanced Gmail Filter topics

** Note ** : Gmail does NOT support search using partial matches, instead GMail

only supports while word searches.  E.g: This does not work: “Find emails that contain any word that starts with Driv%” , The

To and From are the only fields that allow p[artial searching, e.g: find emails that are from @ally.com

Searching:

1. Search Examples using GMails Search Syntax Examples:

Just copy aand paste the below searches into the Gmail search text box to test
  From is from a certain domain:
         from:(@ally.com)
         from:(@ally.com | @expediamail.com)
         same as
         from:(@ally.com OR @expediamail.com)
        
   Before/After Date
         before:2018/9/1
         after:2018/9/1 before:2018/11/18
        
   Before/After Relative Date (instead of specific date)
         newer_than:2d
         older_than:30d
    
   Search multiple labels!
         label:(sent OR inbox)
         label:(sent OR inbox) Indeed
         label:(awork-jobs OR awork-jobs-jobsites) Indeed
         label:(awork-jobs OR awork-jobs-jobsites) older_than:30d

Filtering and Labels

1. Create Gmail Filter to auto label incoming emails:

Requirement:

When an incoming email is received the email shall be saved to a label .\AWork\Jobs\Insurance if the email contains the word Cigna and if the email was not sent from jdoyle@MyDomain.NET

(Create the label first if it does not exist)

How to Build step by Step:

Search:

from:(-from jdoyle@MyDomain.NET) Cigna


Filter:

image_thumb[9]

2. Gmail Filters Syntax


Gmail Filter Syntax Examples for and/or searching:

OR
     to:adam OR subject:iPhone
     is same as
     {to:adam subject:iPhone}


AND
     to:adam AND subject:iPhone
     is same as
     to:adam subject:iPhone
     is same as
     (to:adam subject:iPhone )
   
() parens -> AND
{} brackets -> OR
    


3. Create advanced Filter to auto label incoming emails:

e.g: I need to move emails from Inobx into, I want to move emails based on following requirements:

If incoming email contains the words job or opportunity or contract and email is NOT from a job site alert, then save email to .\AWork\Jobs


If incoming email contains the words job or opportunity or contract and email is NOT from a job site alert AND email has the word Melbourne in it, then save email to .\AWork\Jobs\Melbourne


If incoming email contains the words job or opportunity or contract and email is NOT from a job site alert AND email has the word remote or telecommute in it, then save email to .\AWork\Jobs\Remote



.\AWork\Jobs

(job | opportunity | contract) -{remote from:{alert@indeed.com alerts@ziprecruiter.com inmail-hit-reply@linkedin.com noreply@updates.freelancer.com noreply@updates.freelancer.com info@mail.glassdoor.com noreply@glassdoor.com dartcontainer-jobnotification@noreply.jobs2web.com}} -in:chats


Looks like this:

image_thumb[1]


.\AWork\Jobs\Melbourne

Search:

Find all job emails for melbourne area that are NOT from an automated job site like indeed or ziprecruiter and not in my chats.

(in:anywhere (job | opportunity | contract) (melbourne | "Palm Bay" | Cocoa) -subject:Enterprise -("car rental") -{remote from:{alert@indeed.com alerts@ziprecruiter.com inmail-hit-reply@linkedin.com noreply@updates.freelancer.com noreply@updates.freelancer.com info@mail.glassdoor.com noreply@glassdoor.com dartcontainer-jobnotification@noreply.jobs2web.com}} -in:chats)

Filter:

image_thumb[3]


.\AWork\Jobs\Remote

Search:

((remote | telecommuting | telecommute | remoting) -from:{jdoyle@jrdtechnologies.net alert@indeed.com alerts@ziprecruiter.com inmail-hit-reply@linkedin.com noreply@updates.freelancer.com noreply@updates.freelancer.com info@mail.glassdoor.com noreply@glassdoor.com dartcontainer-jobnotification@noreply.jobs2web.com})


Filter:

image_thumb[5]

When saving a filter be sure to use these options to move an email to a label:

image_thumb[7]

Google Search:

below applies to Google search

1. Google Search by date:

image

 

FYI:

Why Searching using Wildcard in Gmail doesn’t work and some alternatives

https://www.labnol.org/internet/advanced-gmail-search/21623/

http://sirlagz.net/2015/04/27/searching-gmail-with-wildcards/

(online2|online3|online4).provider.com

Tuesday, March 21, 2017

GMail Search & Filters : Search Syntax + some filter examples to auto label emails


References:

Gmail Filters : Exhaustive Syntax Documentation

Some advanced Gmail Filter topics


1. Create Gmail Filter to auto label incoming emails:

Requirement:

When an incoming email is received the email shall be saved to a label .\AWork\Jobs\Insurance if the email contains the word Cigna and if the email was not sent from jdoyle@RDTECHN9OLOGIES.NET

(Create the label first if it does not exist)

How to Build step by Step:

Search:

from:(-jdoyle@jrdtechnologies.net) Cigna


Filter:

image

2. Gmail Filters Syntax


Gmail Filter Syntax Examples for and/or searching:

OR
     to:adam OR subject:iPhone
     is same as
     {to:adam subject:iPhone}


AND
     to:adam AND subject:iPhone
     is same as
     to:adam subject:iPhone
     is same as
     (to:adam subject:iPhone )
   
() parens -> AND
{} brackets -> OR
    


3. Create advanced Filter to auto label incoming emails:

e.g: I need to move emails from Inobx into, I want to move emails based on following requirements:

If incoming email contains the words job or opportunity or contract and email is NOT from a job site alert, then save email to .\AWork\Jobs


If incoming email contains the words job or opportunity or contract and email is NOT from a job site alert AND email has the word Melbourne in it, then save email to .\AWork\Jobs\Melbourne


If incoming email contains the words job or opportunity or contract and email is NOT from a job site alert AND email has the word remote or telecommute in it, then save email to .\AWork\Jobs\Remote



.\AWork\Jobs

(job | opportunity | contract) -{remote from:{alert@indeed.com alerts@ziprecruiter.com inmail-hit-reply@linkedin.com noreply@updates.freelancer.com noreply@updates.freelancer.com info@mail.glassdoor.com noreply@glassdoor.com dartcontainer-jobnotification@noreply.jobs2web.com}} -in:chats


Looks like this:

image


.\AWork\Jobs\Melbourne

Search:

((remote | telecommuting | telecommute | remoting) -from:{jdoyle@jrdtechnologies.net alert@indeed.com alerts@ziprecruiter.com inmail-hit-reply@linkedin.com noreply@updates.freelancer.com noreply@updates.freelancer.com info@mail.glassdoor.com noreply@glassdoor.com dartcontainer-jobnotification@noreply.jobs2web.com})

Filter:

image


.\AWork\Jobs\Remote

Search:

((remote | telecommuting | telecommute | remoting) -from:{jdoyle@jrdtechnologies.net alert@indeed.com alerts@ziprecruiter.com inmail-hit-reply@linkedin.com noreply@updates.freelancer.com noreply@updates.freelancer.com info@mail.glassdoor.com noreply@glassdoor.com dartcontainer-jobnotification@noreply.jobs2web.com})


Filter:

image

When saving a filter be sure to use these options to move an email to a label:

image


3. Google Search by date:

image

 

4. Why Searching using Wildcard in Gmail doesn’t work and some alternatives

https://www.labnol.org/internet/advanced-gmail-search/21623/

http://sirlagz.net/2015/04/27/searching-gmail-with-wildcards/

(online2|online3|online4).provider.com