ऑटोमेशन की सुविधा के लिए क्विकस्टार्ट

एक आसान ऑटोमेशन बनाएं और चलाएं, जो एक Google Docs दस्तावेज़ बनाता है और आपको दस्तावेज़ का लिंक ईमेल करता है.

मकसद

  • स्क्रिप्ट सेट अप करें.
  • स्क्रिप्ट चलाएं.

ज़रूरी शर्तें

इस सैंपल का इस्तेमाल करने के लिए, आपको ये शर्तें पूरी करनी होंगी:

  • Google खाता (Google Workspace खातों के लिए एडमिन की अनुमति की ज़रूरत पड़ सकती है).
  • इंटरनेट ऐक्सेस करने वाला वेब ब्राउज़र.

स्क्रिप्ट सेट अप करें

ऑटोमेशन बनाने के लिए, यह तरीका अपनाएं:

  1. Apps Script एडिटर खोलने के लिए, script.google.com पर जाएं. अगर आप script.google.com पर पहली बार जा रहे हैं, तो डैशबोर्ड देखें पर क्लिक करें.
  2. नया प्रोजेक्ट पर क्लिक करें.
  3. स्क्रिप्ट एडिटर में मौजूद कोई भी कोड मिटाएं और यहां दिया गया कोड चिपकाएं.

    templates/standalone/helloWorld.gs
    /**
     * Creates a Google Doc and sends an email to the current user with a link to the doc.
     */
    function createAndSendDocument() {
      try {
        // Create a new Google Doc named 'Hello, world!'
        const doc = DocumentApp.create('Hello, world!');
    
        // Access the body of the document, then add a paragraph.
        doc.getBody().appendParagraph('This document was created by Google Apps Script.');
    
        // Get the URL of the document.
        const url = doc.getUrl();
    
        // Get the email address of the active user - that's you.
        const email = Session.getActiveUser().getEmail();
    
        // Get the name of the document to use as an email subject line.
        const subject = doc.getName();
    
        // Append a new string to the "url" variable to use as an email body.
        const body = 'Link to your doc: ' + url;
    
        // Send yourself an email with a link to the document.
        GmailApp.sendEmail(email, subject, body);
      } catch (err) {
        // TODO (developer) - Handle exception
        console.log('Failed with error %s', err.message);
      }
    }
  4. 'सेव करें' सेव करने का आइकॉन पर क्लिक करें.

  5. बिना टाइटल वाला प्रोजेक्ट पर क्लिक करें.

  6. अपनी स्क्रिप्ट का नाम डालें और नाम बदलें पर क्लिक करें.

स्क्रिप्ट चलाएं

स्क्रिप्ट चलाने के लिए, इन निर्देशों का पालन करें:

  1. चलाएं पर क्लिक करें.
  2. जब कहा जाए, तब स्क्रिप्ट को अनुमति दें. अगर OAuth के लिए सहमति वाली स्क्रीन पर चेतावनी दिखती है, तो इस ऐप्लिकेशन की पुष्टि नहीं हुई है. बेहतर सेटिंग > को चुनकर जारी रखें {Project Name} पर जाएं (असुरक्षित).

  3. स्क्रिप्ट एक्ज़ीक्यूशन पूरा हो जाने पर, ईमेल के लिए अपना Gmail इनबॉक्स देखें.

  4. वह ईमेल खोलें और जो दस्तावेज़ आपने बनाया है उसे खोलने के लिए लिंक पर क्लिक करें.

अगले चरण