This is really odd that I can't seem to find out how to do this, so I'm wondering if I'm missing something obvious.
I'm wanting to put a menu on our application like is found in Word and Excel, File -> Send To -> Mail Recipient (As Attachment)
Our requirements are to create and display the email with the attachment, just like Word and Excel do, not to send it automatically.
We used to be able to save the file to the temp folder and use:
Shell.Execute("mailto:my.email.com?subject=File&attachment="c:\temp.txt");
I've tried the &attach, &attachment in both VB.NET and C# with quotes, double quotes, etc. I've also tried System.Net.Mail but don't see anywhere that you can display the email, it only seems to be able to create and send.
We can't assume a default email client, it could be Outlook Express, Outlook version 2000, 2003, or 2007, or lotus notes, or ... Don't know. We have a commercial application so I don't think we can assume a specific application. Like MS Word, it needs to work for whatever is installed (or isn't installed).
I've done this using Outlook interop from Visual Studio Tools for Office:
using IntOut = Microsoft.Office.Interop.Outlook;
...
IntOut.Application app = new IntOut.Application();
IntOut.MailItem item = (IntOut.MailItem)app.CreateItem(
IntOut.OlItemType.olMailItem);
item.Subject = "Hello world";
item.Body = "Hello!";
item.Display(false); // set to true to make mail window modal
You can find some samples on MSDN here.
For the general case, there isn't a way to do this. Here's Microsoft's documentation: http://msdn.microsoft.com/en-us/library/aa767737(VS.85).aspx
If you can provide the mail client, you may get a better answer.
Related
i have a problem with MailItem properties in a Outlook VSTO. I add some custom properties to a previously exported .msg mail with e.g. redemption in the following way:
SafeMailItem smi = new SafeMailItem {
Item = mailItem
};
int propertyId = smi.GetIDsFromNames(PROPERTY_GUID, "anyID");
smi.Fields[propertyId] = propertyString;
This property is removed and i cant find it again if i click on sending the mail. I checked this with Outlook Spy and before i send the mail the property is available but after i click on send (and e.g. cancel the send) the property is gone.
I also tried to call MailItem.Save() (at any time) but it has no effect apart from the fact that the .msg file includes the mail edits :). The same behavior is given if i use MailItem.PropertyAccessor directly.
Can anybody explain me why the properties are removed and how to fix this issue?
Thanks a lot for support
Outlook version: 16.0.0.13530 (64-bit); Visual Studio Professional 2019 16.8.4
In my ASP .Net application, I am using 'PDFTron 6.6.0.38591'.
We are using following code to convert Office documents to XOD:
string fileName = Path.GetFileName(pdfTronServiceRequest.FilePath);
fileName = ConstructConvertionFileName(fileName);
outFileName = Path.Combine(outputPath, fileName);
pdftron.PDF.Convert.ToXod(pdfTronServiceRequest.FilePath, outFileName);
response.Result = outFileName;
This code works well for filetypes like docx, xlsx, however for Powerpoint files, no response is returned(request timed out).
On checking the Task Manager window, we can see that a process for 'POWERPNT.exe' is started. However, this process never ends up itself(unlike that in case of word, excel upload).
Also, if I manually ends up this process, the conversion to XOD is successful and response is coming out correctly.
Also, please note that we are facing this issue only when we deploy the code on our test environments. Locally, PPT upload is working fine.
Let me know if you need any other information.
First, you should be running a licensed version of PowerPoint, not a trial/eval one. In particular, the account (including a Service/App Pool account) needs to have accepted the MS office licensing to make sure Office is a fully licensed product.
Also, is this happening with any ppt file or only certain ones? If certain ones, then try using one of the following two flags.
pdftron.PDF.Convert.Printer.SetMode(mode)
e_printer_only
e_interop_only
Finally, switch to the latest version. Which at the very least should provide a lot more debugging info in the exception message.
I'm pulling up the Global Address List from Outlook like so...
Microsoft.Office.Interop.Outlook.Application oApp = new Microsoft.Office.Interop.Outlook.Application();
AddressList gal = oApp.Session.GetGlobalAddressList();
...with the aim of eventually being able to search through this in my own application to retrieve contact information which I can then supply to a method that squirrels off an email. Unfortunately given that my own GAL has about 20K entries in (the customers much more) using a foreach or something simply doesn't work in an acceptable timeframe.
I want to pass a string like "Tom" to a method and have it return a list of possible contacts. Is this possible outside of actually opening up Outlook and creating the mail there?
Note: There are a couple of other questions similar to this but most seem to have no good answer. I'm hoping I have more luck.
Ok, after a LOT of Googling and stress I still haven't come up with a good way to do this. My work around is to search the local contacts folder of a user using this MSDN example. The local contacts folder of any of my users is generally well under a thousand (actually normally well under a hundred) and so there is no real overhead to searching it.
If the users local directory turns up nothing (or they try and send an email to an invalid address using my apps email functionality) then I get Outlook to provide me with with a non-modal "new email" window which has all the body, attachments, title and so on built for me, and the user can use Outlooks search functionality to find the address from the GAL.
Sort of like this...
if(CantFindAddressesLocally)
{
MailItem email = (MailItem)(oApp.CreateItem(OlItemType.olMailItem));
email.Subject = "MY SUBJECT";
email.Body = "MY BODY";
email.Attachments.Add(myAttachment);
email.Display(false) //popup an Outlook "New Email" window
}
Admittedly clumsy since it requires using the Outlook interface (and avoiding that was the whole point of incorporating email functionality in the first place) but at least it generates an email - the only thing left to the user is to input an address that is actually valid.
I am using C# and need to attach a lnk (shortcut/link) file and email it to a lotus notes account. The problem is the icon defaults to a generic image and does not show the folder with the arrow as seen in Windows Explorer. A txt file icon does display as expected. I would like to control the appearance of that icon after it has been received. Can this be done through C# or is the Notes server the problem?
I think you are asking how to control the appearance of the icon once it arrives in the recipient's mail.
I do remember (from when we were on Notes here at work) that the icon was specific to the sender as opposed to the recipient (i.e. if I send you a Word document and I have Word 97 installed and you have 2003 installed, you'll see the Word 97 doc icon). But this appeared to be a function of the fact that I, the sender, was using Notes as the sending client. However, I think you may not be able to do what you want to do as one would assume you are sending regular SMTP e-mail. Assuming you are sending e-mail through the Notes server's SMTP interface, I don't believe you'll be able to control how the link appears on the recipient's side.
I'm new to the world of C# programming but was hoping someone could help me out.
I'm trying to use C# to open up a blank email in Outlook with a specified attachment.
In other words, open the email, the TO: and SUBJECT: fields are blank but the email has an attachment that is specified in my code. I want my user to be able to modify the email and send to whatever users s/he specifies. I know for sure that we have Exchange....so any ideas?
There are a number of way you can do this.
Create an Outlook addin that opens a new mail with the attachment you want via say a new toolbar button.
Do the same in Outlook VBA macro ..
Also you could create a new form with the attachment in it already and then just us that form.(but the attachment will be hard coded etc.)
Does the attachment change ? or is it the same one evey time ? what outlook version are you using ? What are you programing capabilties ?
76mel
I don't think exchange will help you much, you need to work with outlook on the users machine. You can add a reference to the Outlook interop assemblies, should be in the Com tab of your add references dialog.
Here's some links to jump start you.
http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.aspx
http://www.microeye.com/resources/res_tech_vsnet.htm
Good Luck!