Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all 30032 articles
Browse latest View live

How to send email confirmation using gem devise&mailgun

$
0
0

I am having troubles with sending email confirmation using devise and mailgun. I have installed devise and changed setting to send email but whenever I signup as a newcomer there is no confirmation email sent. Can anyone specifically explain how to do it? Thanks.

config/environments/developments.rb


Read mail using python with smtplib

$
0
0

I'm able to send mail using python script , here is my code

import smtplib, ssl 

smtp_server = "xxx.yyyy.com"
sender_email = "abcd@efgh.com"
receiver_email = "mnop@efgh.com"
username ='DRAETWK'
password = 'password'
message = """\
Subject: Test Mail

This message is sent from Python."""

context = ssl.create_default_context()
with smtplib.SMTP(smtp_server) as server:   
    server.login(username, password)
    server.sendmail(sender_email, receiver_email, message)
    print('Mail Sent... Check your inbox')

Mail send code is working but when I use the same user details I'm not able to read my mail I'm getting login FAILED issue , here is the code

import imaplib
import email.header
from smtplib import SMTP as SMTP


host = 'xxx.yyyy.com'
user = 'abcd@efgh.com'

login_user= 'qweqwr'
password = 'xsw2zsadsadaaq1'


# Connect to the server
print('Connecting to ' + host)
mailBox = imaplib.IMAP4_SSL(host)
mailBox.debug = 100
print(mailBox)
# Login to our account
mailBox.login(login_user, password) 

can someone help ?

MFMailComposeViewController does not send email or dismiss

$
0
0

I'm using MFMailComposeViewController in a view controller with the following code:

if !MFMailComposeViewController.canSendMail() {
    return
}
let mailComposeViewController = MFMailComposeViewController()
mailComposeViewController.mailComposeDelegate = self
present(mailComposeViewController, animated: true)

And:

extension MyViewController : MFMailComposeViewControllerDelegate {
    private func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
        controller.dismiss(animated: true, completion: nil)
    }
}

The MFMailComposeViewController shows as expected, but has the following behavior:

  • Cancel button either does nothing (if the message has not been edited) or shows the "Delete Draft"/"Save Draft" action sheet, none of the options of which dismiss the MFMailComposeViewController
  • The send button does nothing, whether or not it's disabled (no recipient set) or enabled (recipient set)
  • The view can be dismissed by swiping it down (new iOS 13 modal behavior)

This is Xcode 11.2, iOS 13.2, Swift 4.

How can I fix this?

How to send a URL to an Angular project with route params?

$
0
0

I'm creating a small application to register users. To do it, I send a confirmation email to the registered email, example: hello@world.com

The problem is that the Confirmation URL contains a token in URL Params, example: domain.net/#/reset-password/lajcNE9kasmlmkdas4359301fasldkm

When I get the email and then click over the link, my Angular app loads without params.

I already tried to do it with query params just like this: domain.net/#/reset-password?token=lajcNE9kasmlmkdas4359301fasldkm

And still not works

I inject the ActivatedRoute from @angular/router in the component constructor

constructor(public route: ActivatedRoute) {
}

This is the code I'm using to get the route params.

this.route.params.subscribe(params => {
    if (params['token']) {
    }
})

I expect to get the token from the URL, but the token is null, and the URL in the browser is just domain.net/#/ without the params present in the link sent to the email.

How to configure both Maligun & Zoho through your own domain to receive emails

$
0
0

I have a domain mysite.com. I'm new to DNS, so this is probably a basic question.

I want emails to go through Mailgun and be pushed to Zoho.com if they are personal. For instance, myname@mysite.com I want to go to my account at zoho.com, but support@mysite.com I want Mailgun to push to a Gmail account.

Currently, I added both DNS records, but mail is forwarded to higher priority one.

Is there an easy way to configure this at Mailgun?

Cannot POST /index.php

$
0
0

I am new to php and I'm trying to get a contact form to send to my email. Every time I click the submit button, it redirects me to a page that says 'Cannot POST /index.php'. I have tried running it from localhost and deployed it to heroku, and still get the same error. The html and php files are in the same folder.

The console states the following error: 'Failed to load resource: the server responded with a status of 404 (Not Found)'.

The HTML code for the form is

<form name="sentMessage" role="form" id="contactForm" novalidate name="contactform" method="post" action="index.php">
                <div class="control-group form-group">
                    <div class="controls">
                        <label for="first_name">Full Name:</label>
                        <input type="text" class="form-control" name="name" id="name" required data-validation-required-message="Please enter your name.">
                        <p class="help-block"></p>
                    </div>
                </div>
                <div class="control-group form-group">
                    <div class="controls">
                        <label for="telephone">Phone Number:</label>
                        <input type="tel" class="form-control" id="phone" name="telephone" required data-validation-required-message="Please enter your phone number.">
                    </div>
                </div>
                <div class="control-group form-group">
                    <div class="controls">
                        <label for="email">Email Address:</label>
                        <input type="email" class="form-control" name="email" id="email" required data-validation-required-message="Please enter your email address.">
                    </div>
                </div>
                <div class="control-group form-group">
                    <div class="controls">
                        <label for="comments">Message:</label>
                        <textarea rows="10" cols="100" class="form-control" name="message" id="message" required data-validation-required-message="Please enter your message" maxlength="999" style="resize:none"></textarea>
                    </div>
                </div>
                <div id="success"></div>
                <!-- For success/fail messages -->
                <button type="submit" class="btn btn-primary" id="send-email">Send Message</button>
                <div class="form-group">
                    <div class="col-sm-10 col-sm-offset-2">
                        <?php echo $result; ?>  
                    </div>
                </div>
            </form>

The PHP file is:

<?php
if (isset($_POST["submit"])) {
    $name = $_POST['name'];
    $email = $_POST['email'];
    $message = $_POST['message'];
    $telephone = $_POST['telephone'];
    $from = 'Demo Contact Form'; 
    $to = 'example@bootstrapbay.com'; 
    $subject = 'Message from Contact Demo ';

    $body = "From: $name\n E-Mail: $email\n Message:\n $message";

    // Check if name has been entered
    if (!$_POST['name']) {
        $errName = 'Please enter your name';
    }

    //Check if simple anti-bot test is correct
    if (!$_POST['telephone']) {
        $errName = 'Please enter your telephone number';
    }

    // Check if email has been entered and is valid
    if (!$_POST['email'] || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
        $errEmail = 'Please enter a valid email address';
    }

    //Check if message has been entered
    if (!$_POST['message']) {
        $errMessage = 'Please enter your message';
    }

// If there are no errors, send the email
if (!$errName && !$errEmail && !$errMessage && !$errHuman) {
    if (mail ($to, $subject, $body, $from)) {
        $result='<div class="alert alert-success">Thank You! I will be in      touch</div>';
 } else {
    $result='<div class="alert alert-danger">Sorry there was an error sending your message. Please try again later</div>';
}
}
    }
?>

Thanks for the help.

Is there a plugin available to email Nunit tests results in nunit framework?

$
0
0

I am running some nunit test .dll using nunit_console.exe in a test machine, no VS installed, nunit framework and required dlls copied on the machine. I want to email the results to the Stakeholder to notify that the tests are complete.

I expect the output to be an email which says the tests are completed and result is available at a particular location. Or the result could be attached in the email.

VML background image positioned on bottom for Outlook

$
0
0

I am creating an email which has to be look good on Outlook. On the email, I have a paragraph of text (which heights amounts to 324px), and I need a background image (height: 153px) located on the bottom of the paragraph.

I now have the below codes:

<td align="center" valign="top" background="background.png" style="background-repeat: no-repeat;background-position:bottom;background-size: contain;" height="324" bgcolor="#ffffff">
      <!--[if gte mso 9]>
      <v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="width: 620px;height: 153px;">
        <v:fill type="frame" src="background.png" color="#ffffff"  />
      <![endif]-->
      Body Text here
    <!--[if gte mso 9]>
      </v:rect>
      <![endif]-->
    </td>

The current problem is:

  1. The background image is not to scale. It's stretched to the full height of the paragraph.
  2. I'm not sure how to position it on the bottom of the paragraph.

Can anyone good at VML help me with this? Thanks a lot!


Any way to create a mail to a lot of users with JS?

$
0
0

I have to display on the screen a mail, and populate it with a long list of users. (+30-50).

I tried with window.open(mailto)& href.location=mailto, but I think the URL its too long, and sometimes the mail doesn't appear. With <20 users always works, for example.

So I want to know if there is another way to generate a mail, with JS, that can populate the mail to a lot of users.

Exchange 365, mail as other domain that's not ours [closed]

$
0
0

My problem is we have exchange 365. Now we have a email. Let's say. John@ourdomain.com Now my manager wants that if we send mail from john@ourdomain.com that it sends every thing as "someoneelse@awholeotherdomain.com".

Now for all I know that's spam, but who knows I might be wrong. Is there a way to do it that's works this way with exchange 365 that's legit?

Hope someone can help me.

outlook.com how to target css at a specific class

$
0
0

I am designing an HTML email and I've made it look as good as I can in the email clients I have tested. I'm checking it now it Outlook.com and it has some issues (probably because they don't support margins) so I want to add some conditional styles for that client.

I know that Outlook.com wraps the email in a .ExternalClass class and prepends any custom classes with ecx so I tried something like

* {color:black;}
.ExternalClass * {color:red;}
.ExternalClass .ecxMyClass {color:blue;}
.ExternalClass .MyClass {color:green;}

just to see what selector would change the color of the text. I can't get any of them to work. Also I can't find where my styles are defined using an inspector like Firebug..

According to http://www.campaignmonitor.com/css/ Outlook.com should support style tags in the head or body and should be able to use classes as selectors.

Pretty much all of my styles are defined inline but I want to add padding to an element only in Outlook.com so I can't just add it inline. How do I target my custom class element in Outlook.com?

Sendgrid 550 unauthenticated senders not allowed laravel swiftmailer

$
0
0

When I'm using SendGrid to send email in Laravel, it results in the following error:

"550 unauthenticated senders not allowed"

I couldn't find out why this happens. So far, I've configured sender authentication from SendGrid account and created an API key, which is used as a password and username as apikey.

I've also tried with the same set of credentials (username and password) from SendGrid, but this also didn't work.

My .env file sets these mail parameters:

MAIL_DRIVER=smtp
MAIL_HOST=smtp.sendgrid.net
MAIL_PORT=587
MAIL_USERNAME=apikey
MAIL_PASSWORD=API Key
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=test@gmail.com
MAIL_FROM_NAME="text.com"

Batch VIVA Scheduling and Email Sending [closed]

$
0
0

I want to build an email notifier that will import data from excel CSV and then send emails to each recipient one by one with some email body.

Where is the documentation what $mailable string of is Mail::assertNotQueued()?

$
0
0

I've been doing some mail tests in Laravel this morning, which worked.

Now I wanted to test the queue and saw Mail::assertNotQueued(...)

like it says in the Laravel Docs. The method requires a $mailable string. See here the details. But I looked over the docs and I didn't find anything that says what this 'mailable string' is...

Doing Mail::assertNotQueued(new WorkflowEMail());, obvioslly faild, because class != string.

Here my Test Class:

class WorkflowEmailTest extends TestCase
{
use DatabaseMigrations;

/** @test **/
public function an_workflow_email_is_send()
{

    //$this->markTestSkipped('must be revisited.');
    $this->withoutExceptionHandling();

    Mail::fake();

    Mail::assertNotQueued(new WorkflowEMail());

    Mail::to('test@apitest.test')->send(new WorkflowEMail());

    Mail::assertQueued(WorkflowEMail::class,1);

}

Can anyone point me to the docs or tell me how to test this properly?

How to take screenshot of an Outlook.com email message?

$
0
0

With Gmail, you could print the message which opens a new window with just the email message, then you can use any screenshot Chrome extension to capture the entire page.

However Outlook.com messages are always in a frame(?) and screenshot tools can't scroll through the message. How would you save the email to an image file this way? outlook.com email message


CNAME & MX record for yandex mail redirects to yandex.ru

$
0
0

I've set: CNAME ->host: mail, record value: domain.yandex.net.
MX -> host: @, record value: mx.yandex.net. , priority: 10
TXT -> host: @, record value: v=spf1 redirect=_spf.yandex.net

mail.mydomain.tld redirects to passport.yandex.ru instead of passport.yandex.com

How do I fix this problem?

Read .eml file and view in web browser using javax.mail

$
0
0

I'm not a very experienced developer (in Java) but I need to read a .eml file and view the body content in the browser (with images) and link to any attachments.

I tried to create three files:

Index.htmt home page whit a button to start the read.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN""http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Read EML file</title>
</head><body>
<h1>Read Email</h1>
<p>Click here to read the eml example file.</p>
<form action="MailServlet" method="post">
<table cellspacing="5" border="0">
<tr><td></td><td><input type="submit" value="Read" /></td></tr></table>
</form>
</body></html>

MailServlet.java connector by html and java

package email;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import helper.MailUtility;

public class MailServlet extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
    private static final long serialVersionUID = 1L;

public MailServlet(){ super(); }

  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException
  {
      response.setContentType("text/html");
      PrintWriter out = response.getWriter();
      String myEMLpath = "C:\\pippo\\test.eml";

        try
        {
            String[] myEML = MailUtility.displayEML(myEMLpath);

            for(int i=0;i<myEML.length;i++) {
                out.println("<br/>" + myEML[i] +"<br/>"); 
            }
        }
        catch (Exception exc)
        {
          out.println("*** catch ***"); 
          out.println("Error: Lettura file KO!");
          log(exc.toString());
        }   
  }

  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException
  {
    this.doPost(request, response);
  }
}

MailUtility.java function to read the eml file.

package helper;

import javax.mail.internet.*;
import javax.mail.BodyPart;
import javax.mail.Header;
import javax.mail.Multipart;
import javax.mail.Session;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class MailUtility {

    public static String[] mytest() throws Exception{
        String[] mymessageArray = new String[20];
        mymessageArray[0] = "my Array String";

        return mymessageArray;

    }

     public static String[] displayEML(String emlFile) throws Exception{

         Properties props = new Properties();
         Session mailSession = Session.getDefaultInstance(props, null);
         InputStream source = new FileInputStream(emlFile);
         MimeMessage message = new MimeMessage(mailSession, source);

         String emlSubject = "Subject : " + message.getSubject();
         String emlFrom = "From : " + message.getFrom()[0];
         String emlBody = "Body : " +  message.getContent();
         String emlAttach = "Attachment: ";

         String contentType = message.getContentType();

         if (message.isMimeType("multipart/*")) {
             System.out.println("message.isMimeType");
         }

         if (contentType.contains("multipart")) {

            Multipart multiPart = (Multipart) message.getContent();
            System.out.println("multiPart: " + multiPart);
            int numberOfParts = multiPart.getCount();
            System.out.println("numberOfParts: " + numberOfParts);

            for (int partCount = 0; partCount < numberOfParts; partCount++) {

                MimeBodyPart part = (MimeBodyPart) multiPart.getBodyPart(partCount);
                if(part.getFileName()!=null) {
                    emlAttach = emlAttach + "<br/>" + part.getFileName();
                }
                emlBody = "body";
                System.out.println("emlBody: " + emlBody);
            }
         }
         String[] mymessageArray = {emlSubject,emlFrom,emlAttach,emlBody}; 
         return mymessageArray; 
        }
}

But I can't read the email body, how can I implement my function to see the email body with images (as signature) and file attached?

Thanks for your support. Marco

How to change JavaMail port

$
0
0

I'm writing a small Java app using JavaMail that sends the user an automated email. They can choose between (for now) two ports: 25 and 587. The port can be selected via a radio button on the GUI.

I added a test button to allow the user to test the email settings (including port). However, for some reason, once the user tries to send a test email, the port can't be changed. Javamail will always use the port of the original test email.

Example: User tries to send an email on port 25 and JavaMail says it can not connect on port 25 (for example, the SMTP host uses another port). User clicks port 587, and tries to send a new email. JavaMail throws an error saying it can not connect on port 25, again.

I'm kind of stumped as to why. Every time a new test email is sent an entirely new SendMailUsingAuthentication object is created. Within that class the properties are always reset to the proper port. Whenever I debug, as far as I can see, all variables are correct and associated with the correct port. Is there something going on inside of Transport that I'm missing?

In the front end GUI:

private void testButtonActionPerformed(java.awt.event.ActionEvent evt) {                                           

    int port = port25RadioButton.isSelected() ? PORT_25 : PORT_587;
    notifier = new SendMailUsingAuthentication(hostNameTextField.getText(),
            userTextField.getText(), getPassword(), emailTextField.getText().split(","),port);


    Thread wait = new Thread(new Runnable() {

        public void run() {
            try {
                changeStatusText("Sending test email...");
                notifier.postTestMail();
                changeStatusText("Test email sent.");
            } catch (AddressException ex) {
                changeStatusText("Error.  Invalid email address name.");
            } catch (MessagingException ex) {
                changeStatusText("SMTP host connection refused.");
                System.err.println(ex.getMessage());
            } catch (Exception ex) {
                System.err.println(ex);
            }
        }
    });

    wait.start();
}

In the email sender class:

public void postTestMail() throws MessagingException, AddressException{
    String[] testReciever = new String[1];
    testReciever[0] = emailList[0];
    postMail(testReciever, "Test email.", "Your email settings are successfully set up.", emailFromAddress);
}

private void postMail(String recipients[], String subject,
        String message, String from) throws MessagingException, AddressException {

    //Set the host smtp address
    Properties props = new Properties();
    props.put("mail.smtp.port", smtpPort);
    props.put("mail.smtp.host", smtpHostName);
    props.put("mail.smtp.auth", "true");
    props.put("mail.smtp.starttls.enable", true);
    Authenticator auth = new SMTPAuthenticator();
    Session session = Session.getDefaultInstance(props, auth);
    session.setDebug(false);

    // create a message
    Message msg = new MimeMessage(session);

    // set the from and to address
    InternetAddress addressFrom = new InternetAddress(from);
    msg.setFrom(addressFrom);

    InternetAddress[] addressTo = new InternetAddress[recipients.length];
    for (int i = 0; i < recipients.length; i++) {
        addressTo[i] = new InternetAddress(recipients[i]);
    }
    msg.setRecipients(Message.RecipientType.TO, addressTo);

    // Setting the Subject and Content Type
    msg.setSubject(subject);
    msg.setContent(message, "text/plain");
    Transport.send(msg);
}

Include an attribute to order email (woocommerce)

$
0
0

I want to add product attribute 'Colorcode' to the admin order email.

This way it'll be easy for the office staff to look for what is actually ordered in case product title does not match.

I am a very beginner with programming and still learning how to deal with woocommerce hooks and php functions. So far I have this code in my:

--- > functions.php

function echo_1($attribute_value){ echo $attribute_value['pa_colorcode']; }

add_action('atr_colorcode', 'echo_1');

--- > and this in my email-order-items.php

do_action('atr_colorcode', array('кц') );

Apparently it is not working. Please help.

Code gets runs successfully but the mail is not getting generated when using selenium

$
0
0

Hi i am trying to get the current URl of the page which need to be formed as table format in mail and the mail need to be sent to the recipients.

I have written the code,code runs successfully but the mail is not getting generated?

Is there any other thing i need to add to the code?

public class Mail extends JFrame {

public static String start = "<html>\n" +
        "<head>\n" +
        "<style>\n" +
       "table, th, td {\n" +
        "  border: 1px solid black;\n" +
        "  border-collapse: collapse;\n" +
        "}\n" +
        "</style>\n" +
        "</head>\n" +
        "<body>\n" +
        "Hi,<br>";
public static String htmlMsg ="";

private JPanel contentPane;

/**
 * Launch the application.
 */
public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                Mail frame = new Mail();
                frame.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}

/**
 * Create the frame.
 */
public Mail() {
    htmlMsg = htmlMsg.concat("<br><br>Mobile TestRail Links <br>"+
            "<table style=\"width:100%\">\n" +
            "<tr bgcolor=\"#F83911\">\n" +
            "<th>Locale</th>\n" +
            "<th>TestRail Link</th>\n" +
            "</tr>\n");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 512, 263);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(null);

    JLabel lblNewLabel = new JLabel("zzz:");
    lblNewLabel.setBounds(10, 11, 104, 20);
    contentPane.add(lblNewLabel);

    JComboBox comboBox = new JComboBox();
    comboBox.addItem("abc");
    comboBox.addItem("cde");

    comboBox.setBounds(124, 11, 331, 20);
    contentPane.add(comboBox);          

    JLabel lblNewLabel_1 = new JLabel("1");
    lblNewLabel_1.setBounds(10, 53, 79, 34);
    contentPane.add(lblNewLabel_1); 

    List<JCheckBox> locales = new ArrayList<JCheckBox>();

    JCheckBox chckbxNewCheckBox = new JCheckBox("ram");
    chckbxNewCheckBox.setBounds(17, 94, 63, 23);
    contentPane.add(chckbxNewCheckBox);
    locales.add(chckbxNewCheckBox);

    JCheckBox chckbxNewCheckBox_1 = new JCheckBox("john");
    chckbxNewCheckBox_1.setBounds(104, 94, 63, 23);
    contentPane.add(chckbxNewCheckBox_1);
    locales.add(chckbxNewCheckBox_1);

    JCheckBox chckbxNewCheckBox_2 = new JCheckBox("man");
    chckbxNewCheckBox_2.setBounds(177, 94, 72, 23);
    contentPane.add(chckbxNewCheckBox_2);
    locales.add(chckbxNewCheckBox_2);

    JCheckBox chckbxNewCheckBox_3 = new JCheckBox("boy");
    chckbxNewCheckBox_3.setBounds(17, 133, 63, 23);
    contentPane.add(chckbxNewCheckBox_3);
    locales.add(chckbxNewCheckBox_3);

    JCheckBox chckbxNewCheckBox_4 = new JCheckBox("qwe");
    chckbxNewCheckBox_4.setBounds(104, 133, 63, 23);
    contentPane.add(chckbxNewCheckBox_4);
    locales.add(chckbxNewCheckBox_4);

    JCheckBox chckbxNewCheckBox_5 = new JCheckBox("asd");
    chckbxNewCheckBox_5.setBounds(177, 133, 72, 23);
    contentPane.add(chckbxNewCheckBox_5);
    locales.add(chckbxNewCheckBox_5);

    JCheckBox chckbxNewCheckBox_6 = new JCheckBox("987");
    chckbxNewCheckBox_6.setBounds(17, 174, 63, 23);
    contentPane.add(chckbxNewCheckBox_6);
    locales.add(chckbxNewCheckBox_6);

    JCheckBox chckbxNewCheckBox_7 = new JCheckBox("321");
    chckbxNewCheckBox_7.setBounds(104, 174, 63, 23);
    contentPane.add(chckbxNewCheckBox_7);
    locales.add(chckbxNewCheckBox_7);

    JCheckBox chckbxNewCheckBox_8 = new JCheckBox("qwe");
    chckbxNewCheckBox_8.setBounds(177, 174, 72, 23);
    contentPane.add(chckbxNewCheckBox_8);
    locales.add(chckbxNewCheckBox_8);

    JButton btnNewButton = new JButton("qweert");
    btnNewButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent arg0) {


            if(comboBox.getSelectedItem().equals("abc"))
            {
                System.setProperty("webdriver.chrome.driver","call from path");
                WebDriver aru=new ChromeDriver();
                aru.manage().window().maximize();
                aru.get("https://example.com");

                //Login
                aru.findElement(By.id("name")).sendKeys("zzz");
                aru.findElement(By.id("password")).sendKeys("yyy");
                aru.findElement(By.id("button_primary")).click(); //Login
                //aru.findElement(By.xpath("//*[@id=\"button_primary\"]/span")).click();
                //aru.findElement(By.className("loginpage-button-sso-disable loginpage-button-sso-disable-hover  loginpage-button-sso-disable-active")).click();
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

                for(JCheckBox checkbox : locales)
                {
                    if(checkbox.isSelected())
                    {
                        aru.get("xyz.com");
                        aru.findElement(By.xpath("//*[@id=\"suite-22496\"]/div[2]/div[1]/a")).click();
                        try {
                            Thread.sleep(3000);
                        } catch (InterruptedException e1) {
                            // TODO Auto-generated catch block
                            e1.printStackTrace();
                        }

                        aru.findElement(By.xpath("//*[@id=\"content-header\"]/div/div[2]/a[1]")).click();
                        aru.findElement(By.xpath("//*[@id=\"includeSpecific\"]")).click();
                        aru.findElement(By.xpath("//*[@id=\"includeSpecificInfo\"]/a")).click();
                        try {
                            Thread.sleep(5000);
                        } catch (InterruptedException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }

                        aru.findElement(By.xpath("//*[@id=\"selectCasesNode-744350\"]/input")).click();
                        aru.findElement(By.id("selectCasesSubmit")).click();


                        aru.findElement(By.id("name")).clear();
                        DateFormat today = new SimpleDateFormat("MM/dd/yyyy ");
                        Date palani = new Date();
                        String content= today.format(palani);
                        try {
                            Thread.sleep(5000);
                        } catch (InterruptedException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                        aru.findElement(By.id("name")).sendKeys("aaa" + checkbox.getText() + " - "+content);


                        //Mail text locales
                        htmlMsg = htmlMsg.concat(
                                "<tr>\n" +
                                        "<td align=\"center\">" + checkbox.getText() + "</td>\n" +
                                        "<td align=\"center\">" + aru.getCurrentUrl()+ "</td>\n" +
                                        "</tr>\n");
                        htmlMsg = htmlMsg.concat("</table><br><br>\n");
                    }

                    else
                    {

                    }       
                }
            }                       
            else
            {
                JOptionPane.showMessageDialog(null, "Please select from list");
            }

        }
    });
    btnNewButton.setBounds(285, 122, 169, 34);
    contentPane.add(btnNewButton);
}

public static void se(String msg) throws AddressException, MessagingException {
    Properties props = new Properties();
    props.put("mail.smtp.host", "smtp.example.com");
    Session session = Session.getDefaultInstance(props);
    try {
        Message message = new MimeMessage(session);
        message.setFrom(new InternetAddress("syz@gmail.com"));
        message.addRecipients(Message.RecipientType.TO, InternetAddress.parse("abc@gmail.com"));
        message.setSubject("Vurrent URlLinks");
        msg = start + msg +
                "<br>Note: This is an automated email , please don't reply to this email. ""</body>\n" +
                "</html>";
        System.out.println(msg);
        message.setContent(msg, "text/html");
        Transport.send(message);
        System.out.println("=====Email Sent=====");
    } catch (MessagingException e) {}}

}

Viewing all 30032 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>