大哥, 我用Javamail实现了发送邮件, 能不能发送出去的邮件不要显示在已发送文件夹呢?
能删除掉已发送出去的邮件吗?. 谢谢了
回复讨论(解决方案)
在已发送文件夹删除一次。
又是大哥
我是用下面的代码, 在已发送文件夹删除一次有什么代码没有?谢谢,你真好
try {
mState = NONE;
Properties props = System.getProperties();
props = System.getProperties();
if (mailType == MailType.TYPE_GMAIL) { // 如果为gmail邮箱,需要设置下两项
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.port", "587"); // gmail smtp port 587 / 465
}
props.put("mail.smtp.host", mSmtp_host);
props.put("mail.smtp.user", mFrom_userName);
props.put("mail.smtp.password", mFrom_passWord);
props.put("mail.smtp.auth", "true");
mSession = Session.getDefaultInstance(props, null);
mSession.setDebug(false);
mMimeMsg = new MimeMessage(mSession);
mMimeMsg.setFrom(new InternetAddress(mFrom_userName));
// mMimeMsg.setContent(mContent, "text/html;charset=utf-8");
if (mToId != null)
setSendToMsg(mToId);
if (mCcId != null)
setCopyToMsg(mCcId);
if (mBccId != null)
setBCopyToMsg(mBccId);
if (mSubject != null) {
mMimeMsg.setSubject(mSubject);
}
if (mShow_name != null) {
mMimeMsg.setFrom(new InternetAddress(mShow_name + " + mFrom_userName + ">"));
}
if (mContent != null) {
setContentMp(mContent);
mMimeMsg.setContent(mp);
}
if (mFilePath != null) {
addFile(mFilePath);
}
System.out.println(mMimeMsg.getAllRecipients().toString());
Transport transport = mSession.getTransport("smtp");
System.out.println("connecting...");
mState = CONNECTING;
transport.connect(mSmtp_host, mFrom_userName, mFrom_passWord);
//
if(!transport.isConnected())
{
Log.i(Tag, "Connect failure");
return;
}
mState = CONNECTED;
Log.i(Tag, "Connected to " + mFrom_userName + " succuss");
System.out.println("sending...");
mState = SENDING;
transport.sendMessage(mMimeMsg, mMimeMsg.getAllRecipients());
mState = SENDED;
transport.close();
} catch (Exception e) {
System.out.println("failure! ");
Log.d(Tag, " failure! ", e);
e.printStackTrace();
}
先用
Folder defaultFolder = store.getDefaultFolder();
Folder[] allFolder = defaultFolder.list();
获取有什么文件夹,然后根据列表中的文件夹名getFolder
Store store= session.getStore("pop3");store.connect(host,username, password);Folder folder = store.getFolder("文件夹路径"); // 这里根据所选文件夹删除folder.open(Folder.READ_WRITE);//注意这里与读取时的区别Message message[] = folder.getMessages();BufferedReader reader = new BufferedReader ( new InputStreamReader(System.in));for(int i=0;i<message.length;i++){ message[i].setFlag(Flags.Flag.DELETED, true);//我这里是删除了所有的文件,可根据需要来编写代码}folder.close(true);//注意这里与读取的区别,这里是确认删除的操作....store.close();
有两个问题
1。 Folder folder = store.getFolder("文件夹路径");
//文件夹路径里收件箱是“INBOX”,已发送是“SENDBOX”?
2。message[i].setFlag(Flags.Flag.DELETED, true);
//是局部变量, 它的变化好像没反应到邮件服务器?
多谢提供代码
补允:BufferedReader reader is not used ,是不是这里要怎么用一下
有两个问题
1。 Folder folder = store.getFolder("文件夹路径");
//文件夹路径里收件箱是“INBOX”,已发送是“SENDBOX”?
2。message[i].setFlag(Flags.Flag.DELETED, true);
//是局部变量, 它的变化好像没反应到邮件服务器?
多谢提供代码
Folder defaultFolder = store.getDefaultFolder();
Folder[] allFolder = defaultFolder.list();
在这里找。
参考下: http://www.alixixi.com/program/a/2008020835375.shtml
Folder defaultFolder = store.getDefaultFolder(); 只能获得一个“INBOX”
看有个文章说POP3协议下getFolder(name)只支持“INBOX”:
getFolder
public Folder getFolder(java.lang.String name)
throws MessagingException
Only the name "INBOX" is supported.
试用了IMAP,就可以得到所有的文件夹:”INBOX, 草稿箱, 已发送, 已删除, 垃圾邮件, 广告邮件“
而我不想用IMAP,用POP3是没办法得到“已发送”邮件呢?
POP3得到?件箱?件貌似不行。
http://bbs.csdn.net/topics/10021225
我在想outlook, foxmail 是怎么在不开通IMAP协议情况下实现的呢? 谢谢你了

TomodifydatainaPHPsession,startthesessionwithsession_start(),thenuse$_SESSIONtoset,modify,orremovevariables.1)Startthesession.2)Setormodifysessionvariablesusing$_SESSION.3)Removevariableswithunset().4)Clearallvariableswithsession_unset().5)Destroythe

Arrays can be stored in PHP sessions. 1. Start the session and use session_start(). 2. Create an array and store it in $_SESSION. 3. Retrieve the array through $_SESSION. 4. Optimize session data to improve performance.

PHP session garbage collection is triggered through a probability mechanism to clean up expired session data. 1) Set the trigger probability and session life cycle in the configuration file; 2) You can use cron tasks to optimize high-load applications; 3) You need to balance the garbage collection frequency and performance to avoid data loss.

Tracking user session activities in PHP is implemented through session management. 1) Use session_start() to start the session. 2) Store and access data through the $_SESSION array. 3) Call session_destroy() to end the session. Session tracking is used for user behavior analysis, security monitoring, and performance optimization.

Using databases to store PHP session data can improve performance and scalability. 1) Configure MySQL to store session data: Set up the session processor in php.ini or PHP code. 2) Implement custom session processor: define open, close, read, write and other functions to interact with the database. 3) Optimization and best practices: Use indexing, caching, data compression and distributed storage to improve performance.

PHPsessionstrackuserdataacrossmultiplepagerequestsusingauniqueIDstoredinacookie.Here'showtomanagethemeffectively:1)Startasessionwithsession_start()andstoredatain$_SESSION.2)RegeneratethesessionIDafterloginwithsession_regenerate_id(true)topreventsessi

In PHP, iterating through session data can be achieved through the following steps: 1. Start the session using session_start(). 2. Iterate through foreach loop through all key-value pairs in the $_SESSION array. 3. When processing complex data structures, use is_array() or is_object() functions and use print_r() to output detailed information. 4. When optimizing traversal, paging can be used to avoid processing large amounts of data at one time. This will help you manage and use PHP session data more efficiently in your actual project.

The session realizes user authentication through the server-side state management mechanism. 1) Session creation and generation of unique IDs, 2) IDs are passed through cookies, 3) Server stores and accesses session data through IDs, 4) User authentication and status management are realized, improving application security and user experience.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver CS6
Visual web development tools

SublimeText3 Chinese version
Chinese version, very easy to use

Notepad++7.3.1
Easy-to-use and free code editor

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.
