简体   繁体   English

部分类型中的方法setText(String)不适用于参数

[英]method setText(String) in the type Part is not applicable for the arguments

I have to develop one java application. 我必须开发一个Java应用程序。

Here i got the below error: 在这里我得到以下错误:

The method setText(String) in the type Part is not applicable for the arguments (String, String) 部分类型中的方法setText(String)不适用于参数(字符串,字符串)

Here i have to send the retrievedUserName,retrievedPassword to my mail via settext. 在这里,我必须通过settext将retrevedUserName,retrievedPassword发送到我的邮件中。 How can i call the above 2 string value in settext method.please help me.whats wrong in my code. 我该如何在settext方法中调用上述2个字符串值。请帮助我。我的代码有什么错误。

This is my code: 这是我的代码:

      public class SendMail {
      public String authentication(String Product,String Cost){
      String retrievedUserName = "";
      String retrievedPassword = "";
      String retrievedEmail = "";
      String status = "";
      try{
      Class.forName("com.mysql.jdbc.Driver");
      Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/xcart-432pro","root","");

      PreparedStatement statement =  con.prepareStatement("SELECT xcart_products.product,xcart_products.list_price,xcart_customers.email FROM xcart_products,xcart_customers WHERE product = '"+Product+"'");
      ResultSet result = statement.executeQuery();
      while(result.next()){
       retrievedUserName = result.getString("list_price");
       retrievedPassword = result.getString("product");
       retrievedEmail = result.getString("email");
            }
          if(retrievedPassword.equals(Product)){
       status = "The product name is send to your email";
        Properties props = new Properties();
          props.put("mail.smtp.host", "smtp.gmail.com");
         props.put("mail.smtp.socketFactory.port", "465");
        props.put("mail.smtp.socketFactory.class",
        "javax.net.ssl.SSLSocketFactory");
        props.put("mail.smtp.auth", "true");
        props.put("mail.smtp.port", "465");

          Session session = Session.getDefaultInstance(props,
                  new javax.mail.Authenticator() {
                protected PasswordAuthentication getPasswordAuthentication() {
                        new PasswordAuthentication("xxxxx@gmail.com","4242vfgDF!");
                        }
                    });
                   try {

            Message message = new MimeMessage(session);
             message.setFrom(new InternetAddress("krishnaveni.veeman@gmail.com"));
         message.setRecipients(Message.RecipientType.TO,
                    InternetAddress.parse("demo@gamil.com"));
            message.setSubject("Testing Subject");
            message.setText("Dear Friends This is your product name and price"+
                    retrievedPassword,retrievedUserName);

        Transport.send(message);

            System.out.println("Done");

            } 

Try specifying the charset. 尝试指定字符集。 I also use setContent, but I suppose setText would work the same way. 我也使用setContent,但是我想setText将以相同的方式工作。 Try replacing your setText call with this: 尝试将您的setText调用替换为:

 message.setContent("Dear Friends This is your product name and price "+
                     retrievedPassword+retrievedUserName, "text/html; charset=utf-8");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 JLabel类型的setText(String)方法不适用于arguments(File) - The method setText(String) in the type JLabel is not applicable for the arguments(File) 类型为nammi的方法epli(String [])不适用于arguments() - The method epli(String[]) in the type nammi is not applicable for the arguments () 类型“ x”的方法search()不适用于参数(字符串) - The method search() in the type “x” is not applicable for the arguments (String) 类型“x”中的方法 getBytes() 不适用于 arguments(字符串) - The method getBytes() in the type "x" is not applicable for the arguments (String) 类型中的方法不适用于参数 - Method in the type is not applicable to the arguments 类型中的方法不适用于参数 - The method in the type is not applicable for the arguments 类型中的方法不适用于参数 - the method in type not applicable for the arguments 类型中的方法不适用于参数 - The method in the type is not applicable for the arguments JsonObject类型的方法add(String,JsonElement)不适用于参数(String,String) - The method add(String, JsonElement) in the type JsonObject is not applicable for the arguments (String, String) ArrayList类型中的方法add(String) <String> 不适用于参数(对象) - The method add(String) in the type ArrayList<String> is not applicable for the arguments (Object)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM