Hi
I have text files I want to copy the text to MS outlook express. Assist me in writing the code for it
Kritika
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Iftikar HussainPosted Aug 14, 2013, 2:35 AM
kritika RanaPosted Aug 16, 2013, 1:29 AM
Again I have some new queries........
As my program is working properly but I want to sort the files according to date and time mentioned in the very first line of the files.
If possible then guide me completing the project.
I hereby attach sample files for your reference
Regards
Kritika
kritika RanaPosted Aug 14, 2013, 4:24 AM
I have dir test inside their is another dir test2 ,test3 and so on so I want to search the file in all the dir and then send the email.
Hope you understand my question
Thanks
Kritika
Iftikar HussainPosted Aug 14, 2013, 4:06 AM
Regards,
Iftikar
kritika RanaPosted Aug 14, 2013, 3:49 AM
Iftikar HussainPosted Aug 14, 2013, 3:36 AM
dinfo.GetFiles("test*") like this
it will get files start with test
Regards,
Iftikar
kritika RanaPosted Aug 14, 2013, 3:25 AM
Can it be possible that to search for specific file name in different directories with this code.
Thanks
Kritika
Iftikar HussainPosted Aug 14, 2013, 3:20 AM
kritika RanaPosted Aug 14, 2013, 3:10 AM
kritika RanaPosted Aug 14, 2013, 2:55 AM
It it possible to search a specific file from multiple directories sort it and then send as email.
kritika RanaPosted Aug 14, 2013, 1:58 AM
Iftikar HussainPosted Aug 14, 2013, 1:55 AM
kritika RanaPosted Aug 14, 2013, 1:40 AM
Iftikar HussainPosted Aug 14, 2013, 1:30 AM
");
Regards,
Iftikar
kritika RanaPosted Aug 14, 2013, 1:27 AM
Its working now but Can this code send the files one by one to the specified person???
Regards
Kritika
Iftikar HussainPosted Aug 14, 2013, 1:22 AM
mailbox.EnableSsl = true;
Regards,
Iftikar
kritika RanaPosted Aug 14, 2013, 1:21 AM
smtp server requires a secure connection or the client was not authenticated
Iftikar HussainPosted Aug 14, 2013, 1:12 AM
");
kritika RanaPosted Aug 14, 2013, 1:07 AM
Iftikar HussainPosted Aug 14, 2013, 1:04 AM
Regards,
Iftikar
kritika RanaPosted Aug 14, 2013, 1:03 AM
yes i want to use my gmail account.
Iftikar HussainPosted Aug 14, 2013, 1:01 AM
Regards,
Iftikar
kritika RanaPosted Aug 14, 2013, 12:56 AM
Iftikar HussainPosted Aug 14, 2013, 12:55 AM
Regards,
Iftikar
kritika RanaPosted Aug 14, 2013, 12:54 AM
I tried but its not working . Same exception SERVICE NOT AVAILABLE ,CLOSING CHANNEL
Help in resolving the exception..
Regards
Kritika
Iftikar HussainPosted Aug 13, 2013, 6:33 AM
");
kritika RanaPosted Aug 13, 2013, 5:00 AM
mailbox.Send(mailMessage);
kritika RanaPosted Aug 13, 2013, 4:54 AM
mailbox.Send(mailMessage);
Iftikar HussainPosted Aug 13, 2013, 4:24 AM
kritika RanaPosted Aug 13, 2013, 3:47 AM
http://msdn.microsoft.com/en-us/library/cc668191
public partial class ThisAddIn
{
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
Outlook.Inspectors inspectors;
inspectors = this.Application.Inspectors;
inspectors.NewInspector += new Microsoft.Office.Interop.Outlook.InspectorsEvents_NewInspectorEventHandler(Inspectors_NewInspector);
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}
void Inspectors_NewInspector(Microsoft.Office.Interop.Outlook.Inspector Inspector)
{
Outlook.MailItem mailItem = Inspector.CurrentItem as Outlook.MailItem;
if (mailItem != null)
{
if (mailItem.EntryID == null)
{
mailItem.Subject = "This text was added by using code";
mailItem.To = "[email protected]";
System.IO.StreamReader r = new System.IO.StreamReader("D:/Files/");
string body = r.ReadToEnd();
mailItem.Body = body;
}
}
The code given above is working. It will open outlook exp when I click on New Email , To, Subject and body will showing the proper text. But I do not know how to use the add-ins with user controls like buttons. As you know that I need that when I click a button email will be send.
Guide me
Iftikar HussainPosted Aug 13, 2013, 3:37 AM
kritika RanaPosted Aug 13, 2013, 3:13 AM
Iftikar HussainPosted Aug 13, 2013, 2:17 AM
Regards,
Iftikar
kritika RanaPosted Aug 13, 2013, 2:12 AM
Iftikar HussainPosted Aug 13, 2013, 1:55 AM
Regards,
Iftikar
kritika RanaPosted Aug 13, 2013, 1:54 AM
Iftikar HussainPosted Aug 13, 2013, 1:47 AM
mailbox.Credentials = new NetworkCredential(id, password);
Regards,
Iftikar
kritika RanaPosted Aug 13, 2013, 1:45 AM
service not available, Closing transmission channel
kritika RanaPosted Aug 13, 2013, 1:42 AM
private void button6_Click(object sender, EventArgs e)
{
MailMessage mailMessage = new MailMessage();
mailMessage.From = new MailAddress("[email protected]", "Kritika");
mailMessage.To.Add("[email protected]");
mailMessage.Subject = "Test Subject";
mailMessage.IsBodyHtml = true;
string path = @"D:\Files";
DirectoryInfo dinfo = new DirectoryInfo(path);
var files = dinfo.GetFiles("*").OrderByDescending(s => s.LastWriteTime).ToList();
StringBuilder sb = new StringBuilder();
foreach (var fileInfo in files)
{
var filePath = fileInfo.FullName;
using (var textFile = File.OpenText(filePath))
{
sb.Append(textFile.ReadToEnd() + "
");
}
}
mailMessage.Body = sb.ToString();
SmtpClient mailbox = new SmtpClient("ns.tataidc.co.in");
mailbox.Send(mailMessage);
}
Iftikar HussainPosted Aug 13, 2013, 1:32 AM
Regards,
Iftikar
kritika RanaPosted Aug 13, 2013, 1:26 AM
Iftikar HussainPosted Aug 13, 2013, 1:25 AM
Regards,
Iftikar
kritika RanaPosted Aug 13, 2013, 1:21 AM
Iftikar HussainPosted Aug 13, 2013, 1:12 AM
StringBuilder sb=new StringBuilder();
");
Regards,
Iftikar
kritika RanaPosted Aug 13, 2013, 1:02 AM
Iftikar HussainPosted Aug 13, 2013, 12:59 AM
Regards,
Iftikar
kritika RanaPosted Aug 13, 2013, 12:55 AM
Iftikar HussainPosted Aug 13, 2013, 12:53 AM
kritika RanaPosted Aug 13, 2013, 12:50 AM
What you are saying is Ok. But attached files will not be opened on the receivers machine it has to be as the body of the email. This is the requirement.
Regards
kritika
Iftikar HussainPosted Aug 13, 2013, 12:28 AM
Instead of copying data to outlook and then send it, you write code in your application for sending mail by attaching the files like this
Regards,
Iftikar