我已经能够使用Java将图像作为附件发送到电子邮件中.我现在正试图在电子邮件正文中发送相同的图像,如下所示:
public static void main(String[] args) throws NoSuchProviderException, MessagingException {
System.out.println("Sending mail...");
Properties props = new Properties();
props.setProperty("mail.smtp.starttls.enable", "true");
props.setProperty("mail.transport.protocol", "smtp");
props.setProperty("mail.smtp.auth", "true");
props.setProperty("mail.smtp.host", "smtp.gmail.com");
props.setProperty("mail.smtp.port", "587");
props.setProperty("mail.smtp.user", "mysusername");
props.setProperty("mail.smtp.password", "mypassword");
Session mailSession = Session.getDefaultInstance(props, null);
mailSession.setDebug(true);
Transport transport = mailSession.getTransport();
MimeMessage message = new MimeMessage(mailSession);
message.setSubject("HTML mail with images");
message.setFrom(new InternetAddress("myaddress@gmail.com"));
message.setContent
("<h1>This is a test</h1>"
+ "<img src=\"C:/Users/pc/Desktop/Photos/Shammah.PNG\">",
"text/html");
message.addRecipient(Message.RecipientType.TO,
new InternetAddress("receiver@simbatech.biz"));
transport.connect();//This is line 46
transport.sendMessage(message,
message.getRecipients(Message.RecipientType.TO));
transport.close();
}
Run Code Online (Sandbox Code Playgroud)
我得到这个输出:
Sending mail...
DEBUG: setDebug: JavaMail version 1.4ea …Run Code Online (Sandbox Code Playgroud) 我正在使用Java创建一个新文件,但我得到了异常:
Exception in thread "main" java.io.IOException: The device is not ready
at java.io.WinNTFileSystem.createFileExclusively(Native Method)
at java.io.File.createNewFile(File.java:947)
at pdfconverter.PdfConverter.main(PdfConverter.java:96)
Run Code Online (Sandbox Code Playgroud)
Java结果:1
在我的第96行是这个条件:
if (!logfile.exists()) {
logfile.createNewFile();//line 96
}
Run Code Online (Sandbox Code Playgroud)
我之前使用过这个时间,我不明白发生了什么因为我以管理员身份登录.请帮忙.
我创建了一个新的应用程序项目(不是库或框架),然后我将"compile source as"设置为object-C++.但是当我编译源代码时,它显示"build failed".
错误是:
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_UIResponder", referenced from:
_OBJC_CLASS_$_AppDelegate in AppDelegate.o
"_OBJC_METACLASS_$_UIResponder", referenced from:
_OBJC_METACLASS_$_AppDelegate in AppDelegate.o
"_UIApplicationMain", referenced from:
_main in main.o
"_OBJC_METACLASS_$_UIViewController", referenced from:
_OBJC_METACLASS_$_ViewController in ViewController.o
"_OBJC_CLASS_$_UIViewController", referenced from:
_OBJC_CLASS_$_ViewController in ViewController.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)
但令我困惑的是:如果它是一个框架项目,它编译得很好.你能救我一把手!
嗨大家我正在编写Java程序,我需要从Oracle数据库中选择当月的记录.任何时候我需要选择当天的记录我使用:
select * from purchases where purchase_date = to_char(sysdate, 'DD-MON-YYYY')
Run Code Online (Sandbox Code Playgroud)
我应该使用什么方法从当前月份中选择记录?在表格上,日期显示如下:
10/4/2012 //for 4th October 2012
Run Code Online (Sandbox Code Playgroud)
我试过了
select * from purchases where purchase_date like to_char(sysdate, 'MON-YYYY')
Run Code Online (Sandbox Code Playgroud)
这当然没有选择,请协助.
我有一个Java Swing应用程序,我可以使用以下代码设置快捷键.例如Ctrl+ K.
keyHelp.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_K, Event.CTRL_MASK));
keyHelp.setMnemonic((int) 'K');//This is the Line I need Help in
Run Code Online (Sandbox Code Playgroud)
我只是无法弄清楚如何添加相同的使用F1键作为快捷方式...任何人都可以帮助吗?
我在自定义模块扩展中覆盖了核心文件.
使用magento管理面板禁用此模块无效.
system -> configuration -> Advanced
Module Name (drop down option - disable)
Run Code Online (Sandbox Code Playgroud)
提前致谢.
我试图使用JSTL显示数据库数据,如下所示:
我的道
public ArrayList getStudentFirstName(){
ArrayList v = new ArrayList();
Connection conn;
try{
conn = db.getDbConnection();
String sql = "select STU_FIRST_NAME, STU_MIDDLE_NAME, LAST_NAME from college_students_master";
PreparedStatement ps = conn.prepareStatement(sql);
ResultSet rs = ps.executeQuery();
while(rs.next()){
String firstname = rs.getString("STU_FIRST_NAME");
String middlename = rs.getString("STU_MIDDLE_NAME");
String lastname = rs.getString("LAST_NAME");
v.add(firstname);
v.add(middlename);
v.add(lastname);
}
}catch(Exception asd){
System.out.println(asd.getMessage());
}
return v;
}
Run Code Online (Sandbox Code Playgroud)
我的servlet:
public class displayservlet extends HttpServlet {
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
DetailsDao dd = new DetailsDao(); …Run Code Online (Sandbox Code Playgroud) 我有ResultSet方法,我在一个finallly块中关闭Connection:
public static ResultSet countdrcountcr(String vforacid) throws SQLException {
ResultSet rs = null;
Connection conn = null;
try {
conn = db.getDbConnection();
String sql = "SELECT NVL (SUM (DECODE (part_tran_type, 'D', 1, 0)), 0), "
+ " NVL (SUM (DECODE (part_tran_type, 'C', 1, 0)), 0) "
+ " FROM tbaadm.htd WHERE acid IN (SELECT acid "
+ " FROM tbaadm.gam WHERE foracid = '" + vforacid + "') "
+ " AND tran_date >= '22-NOV-2013' AND tran_date <= '30-NOV-2013' " …Run Code Online (Sandbox Code Playgroud) 我实际上以为我可以做到这一点,直到我尝试.我在本地网络IP地址(192.168.1.4)的一台PC上安装了MySQL服务器,现在我试图从同一网络中的另一台PC(192.168.1.5)访问它,但我无法:
C:\Users\DOMICO>mysql -u domico -h 192.168.1.4 -p
Enter password: **********
ERROR 1045 (28000): Access denied for user 'domico'@'DOMICO-PC' (using password:
YES)
Run Code Online (Sandbox Code Playgroud)
令人惊讶的是,DOMICO-PC是我试图连接的PC.为什么它没有连接到给定的主机但是尝试连接到本地计算机?
我需要将文本居中在Pdf表格单元格中.不幸的是,所有文本都出现在单元格的底部.这是我的示例代码:
String line = br.readLine();
Font f2 = new Font(Font.NORMAL, 12, Font.BOLD);
f2.setColor(Color.BLACK);
Paragraph p1 = new Paragraph(line, f2);
p1.setAlignment(Element.TABLE);
PdfPTable table = new PdfPTable(1);
table.setWidthPercentage(100);
PdfPCell cell = new PdfPCell();
cell.setBorder(Rectangle.NO_BORDER);
cell.setBorderWidthBottom(1f);
cell.setUseBorderPadding(true);
cell.setPadding(0);
cell.setBorderColor(new java.awt.Color(255, 255, 255));
cell.addElement(p1);
table.addCell(cell);
output.add(table);
Run Code Online (Sandbox Code Playgroud)
我需要单元格内的文本在单元格内垂直居中.请帮忙.