EzDevInfo.com

outlook-2010 interview questions

Top outlook-2010 frequently asked interview questions

How do I get MS Outlook to accept the CSS style display:block?

I am composing an HTML email using a service (MailChimp). The way that MailChimp marks up headings is to use a SPAN tag and gives the tag the inline style of display:block.

MS Outlook 2010 ignores this style. I cannot find any work around. Thus, headings wrap, breaking the desired page display.

Yes, I know that Outlook uses MS Word to display HTML.

Assume that I cannot intervene and hand edit the markup.

How do I get MS Outlook to accept the CSS style display:block and display a SPAN tag as a block level element?


Source: (StackOverflow)

how to display background color in outlook 2010 html email?

My problem is related to Microsoft Outlook 2010. Actually I want to publish my HTML newsletter in Outlook 2010, but the main problem which I am facing is styling problem it's not showing color and all when the newsletter is published in Outlook 2010. please help me out if you know how to set color and css style in Outlook.


Source: (StackOverflow)

Advertisements

css padding is not working in outlook

I have following html in email template.

I am getting different view in MS Outlook and in gmail for the same.

<tr>
    <td bgcolor="#7d9aaa" style="color: #fff; font-size:15px; font-family:Arial, Helvetica, sans-serif; padding: 12px 2px 12px 0px; ">
    <span style="font-weight: bold;padding-right:150px;padding-left: 35px;">Order Confirmation </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <span style="font-weight: bold;width:400px;"> Your Confirmation number is {{var order.increment_id}} </span></td>
</tr>

In gmail

In outlook

How to fix this?


Source: (StackOverflow)

Read Outlook Events via Python

Outlook has some things to desire - like showing multiple month view

So I decided to give it a try by pulling out the event data via python (and then figure a way to display it nicely). Google is giving me pore results, but stackoverflow has been very helpful previously in regards to using win32com and outlook.

My goals are the following

  • read a shared calendar
  • read the events information like start, end, subject, creater etc

I haven't got far, but this is what I got together (with inspiration from this site)

import win32com.client, datetime
from dateutil.relativedelta import relativedelta

Outlook = win32com.client.Dispatch("Outlook.Application")
ns = Outlook.GetNamespace("MAPI")

appointments = namespace.GetDefaultFolder(9).Items 
# TODO: Need to figure out howto get the shared calendar instead Default [9] 
# (I have placed the shared folder into a separate folder - don't know if it matters)
# I would just like the user to select which calendar to execute on
appointments.Sort("[Start]")
appointments.IncludeRecurrences = "True"
begin = date.today().strftime("%m%d%Y")
end = (date.today() + relativedelta( months = 3 )).strftime("%m%d%Y")
appointments = appointments.Restrict("[Start] >= '" +begin+ "' AND [END] >= '" +end+ "'")

From here I need help with looping through the events and read them. Any help is highly appreciated.


Source: (StackOverflow)

Getting/Creating an Outlook Application in Windows 7

I'm trying to get the current running version of Outlook or start up Outlook in case it is not running, but I am having some issues in getting or creating the Outlook Application object in Windows 7. I think it has something to do with the user priviliges that are restrictive in Vista and 7. I am working with Outlook 2010.

edit: These errors only appear if I already have an Outlook 2010 instance started. If Outlook is not started, the application can run smoothly (it can start an Outlook instance by itself).

If anybody can tell me how to correctly get the Outlook Application version, that would be really helpful.

The code I'm running is a long try-catch block that keeps on triggering exceptions:


try
{
  // create an application instance of Outlook
  oApp = new Microsoft.Office.Interop.Outlook.Application();
}
catch(System.Exception ex)
{
  try
  {
     // get Outlook in another way
     oApp = Marshal.GetActiveObject("Outlook.Application") as Microsoft.Office.Interop.Outlook.Application;
  }
  catch (System.Exception ex2)
  {
     // try some other way to get the object
     oApp = Activator.CreateInstance(Type.GetTypeFromProgID("Outlook.Application")) as Microsoft.Office.Interop.Outlook.Application;
  }
}

The application throws me the following exceptions:

When I try to create a new Outlook application instance:

Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80080005.

When I try to get the Outlook app instance:

Operation unavailable (Exception from HRESULT: 0x800401E3 (MK_E_UNAVAILABLE))

When I try to Create an instance through the Activator

Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80080005.

Thank you!


Source: (StackOverflow)

Can only send email via Outlook if Outlook is open

I want to use send emails via Outlook as described here. It works fine as long as I have already opened Outlook. So for example if Outlook is minimized and I execute my code, then I can send an email just fine. But if Outlook is closed, then I get an exception:

{System.Runtime.InteropServices.COMException (0x80004004): Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT))
   at Microsoft.Office.Interop.Outlook._MailItem.get_Recipients()
   at OutlookExample.Form1.btnSendEmail_Click(Object sender, EventArgs e) in C:\Users\abc\Documents\Visual Studio 2008\Projects\OutlookExample\OutlookExample\Form1.cs:line 28}

Here is the code:

using Outlook = Microsoft.Office.Interop.Outlook;

...

private void btnSendEmail_Click(object sender, EventArgs e)
{
    try
    {
        Outlook.Application oApp = new Outlook.Application();
        Outlook.MailItem oMsg = Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);
            oMsg.HTMLBody = "Hello, here is your message!";
            oMsg.Subject = "This is a test message";
            Outlook.Recipients oRecips = (Outlook.Recipients)oMsg.Recipients;
            Outlook.Recipient oRecip = (Outlook.Recipient)oRecips.Add("rhr@sonlinc.dk");
            oRecip.Resolve();
            oMsg.Send();
            oRecip = null;
            oRecips = null;
            oMsg = null;
            oApp = null;
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.ToString());
    }
}

Edit: Here is the solution

using Outlook = Microsoft.Office.Interop.Outlook;

...

private void btnSendEmail_Click(object sender, EventArgs e)
{
    try
    {
        Outlook.Application oApp = new Outlook.Application();

        // These 3 lines solved the problem
        Outlook.NameSpace ns = oApp.GetNamespace("MAPI");
        Outlook.MAPIFolder f = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
        System.Threading.Thread.Sleep(5000); // test

        Outlook.MailItem oMsg = Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);
            oMsg.HTMLBody = "Hello, here is your message!";
            oMsg.Subject = "This is a test message";
            Outlook.Recipients oRecips = (Outlook.Recipients)oMsg.Recipients;
            Outlook.Recipient oRecip = (Outlook.Recipient)oRecips.Add("rhr@sonlinc.dk");
            oRecip.Resolve();
            oMsg.Send();
            oRecip = null;
            oRecips = null;
            oMsg = null;
            oApp = null;
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.ToString());
    }
}

Why doesn't this work?


Source: (StackOverflow)

Adding a Tab to the Outlook 2010 Ribbon?

I'm trying to create an Outlook 2010 addin that adds a new tab to the ribbon. I found out how I can add my groups to an existing tab by setting the OfficeId to "TabMail" or something built-in, but I don't want to modify existing tabs.

I've now set the OfficeId that something of my own ("TabMyAddin"), but it doesn't show up in Outlook. I wonder if I need to somehow tell Outlook to add it and show it, or how I would proceed?

The RibbonType was changed to Microsoft.Outlook.Explorer if that matters.


Source: (StackOverflow)

change outlook MailItem icon

I'm developing an outlook 2010 addin that exports the emails to a specific locations when an user clicks a button from the menu.

This part is not a problem, but I need also to change the MailItem icon-pictogram if the export was successful. I tried to look for solutions, but I only get that I need to use form regions , but I didn't find a true helpful solution.

Any ideas how should I use this form regions?!


I finished the add-in and everything seems to work perfect when debugging from VS 2010. I also created an installer, but after installing the application the Outlook won't display my icons like I want. Instead of showing what you can see above, it changes the icons, but shows a default one - not mine. The icons are in the resx file from the FormRegion that I used (I use dor default and read icons from manifest) , I also tried to move them to the general Resource file (Properties.Resource), but the result is the same. Can someone help me with this?


So I added a FormRegion using Replacement and ReplaceAll also, added my icon on default icon on manifest, and name it IPM.Note.MyExportedItem.

In the ThisAddin.cs I have the following code:

MailItem mailItem = (selectedItem as MailItem);

                    itemGuid = mailItem.EntryID;
                    string name = mailItem.Subject + ".msg";



                    name = "C:\\" + name.Replace(":", "");
                    try
                    {
                        mailItem.SaveAs(name, OlSaveAsType.olMSG);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                    mailItem.MessageClass = "IPM.Note.MyExportedItem";
                    mailItem.Display(true);

                    ........

But this is not changing the mailItem (email message) icon from Inbox for example to my icon when I export them like I want, the only change that I can see is when I call Display(true) and it opens the mail message. Also if I press New Items, Choose Form and I open my Form Region, it opens a compose message window and if I send an email to me, then it will have my icon...strange...you can see in the picture :-) Do you have any idea what I am doing wrong?

This is how it looks

Regards


Source: (StackOverflow)

VSTO Outlook addin need to save settings, best way?

I'm writing a VSTO Outlook add in and i need to save some settings the addin gets from a web service. What is the best way to do this. Registry? does the VSTO addin have full access to do something like that? Maybe a file containing the settings?

Thanks in advance.


Source: (StackOverflow)

Ribbon button not firing event set by onAction when clicked

I've designed an add-in to Outlook 2010 where I'm trying to fire (or, rather, catch) an event fired when a button is clicked as shown in this article. I've targeted the right XML (since the changes to it are seen on the ribbon). However, The event I'm trying to catch is either not fired at all or (more likely) fired an other way than what my listened is looking (listening?).

I also tried to go by the reference on MSDN here, here and mostly here. To no avail, though... I wonder if it's got to do with the "repurpose" information.

Here's the markup.

<tab idMso="TabMail">
  <group id="group1" label="CRMK">
    <button 
      id="MyId"
      onAction="Button_Click"
      label="Do me!"
      size="large" />
  </group>
  <group id="group2" label="group2">
    <button id="button1" label="button1" showImage="false" />
  </group>
</tab>

And the code behind looks like this.

private void Button_Click(Object sender, RibbonControlEventArgs eventArgs)
{
  MessageBox.Show("Button clicked...");
}

What am I missing? How can I debug such a thing?


Source: (StackOverflow)

Retrieve Current Email Body In Outlook

in my outlook addin I want to add a button on the Ribbon so when user click this button I want to retrieve the current selected email's body , I have this code but it retrieve only the first email from the inbox because the index is 1 :

Microsoft.Office.Interop.Outlook.Application myApp = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.NameSpace mapiNameSpace = myApp.GetNamespace("MAPI");
Microsoft.Office.Interop.Outlook.MAPIFolder myInbox = mapiNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
String body = ((Microsoft.Office.Interop.Outlook.MailItem)myInbox.Items[1]).Body;

so how to retrieve the current opened email in outlook? , this method work for me but I need to get the index for the current email.

Thanks.


Source: (StackOverflow)

Outlook Object Library Does Not Switch Between Versions 12 And 14

I have a .dotm template file on a network share. There are macros with references to the Word, Office, and Outlook object libraries. We use two different platforms, Windows XP and Windows 7, along with Microsoft Office 2007 and Office 2010. When users open the template file the references for Word and Office adjust automatic and accordingly (that is, they’re set to Microsoft Word 12 Object Library or Microsoft Word 14 Object Library as needed), and the macros run without a problem.

Microsoft Outlook Object Library switches properly from version 12 to 14. It does not switch properly from version 14 to 12. In that case, it gives the error that the libary is not found. Is this a bug? Is there a workaround? Something I’m overlooking?


Source: (StackOverflow)

Rendering of zero width table cells in Outlook

First off:
I hate Outlook :)

Here is why:
I am trying to send an email with the following structure (this is just a simplified example so please don't tell me "Just get rid of the middle tds")

<table width="400">
  <tbody>
    <tr>
       <td width="200"><img src="http://lorempixel.com/200/200/"></td>
       <td width="0"></td>
       <td width="0"></td>
       <td width="200"><img src="http://lorempixel.com/200/200/"></td>
    </tr>
  </tbody>
</table>

The problem is, that the two tds in the middle lead to a space between the two pictures as you can see in this screenshot http://i48.tinypic.com/6i8rvk.png

I feel like I have already tried everything possible.

  • cellpadding = 0, cellspacing = 0, border = 0 on table
  • setting the width of every td with inline css
  • adding border-collapse: collapse to all tds and the table
  • adding margin:0, padding:0; border 0; to all tds in inline css
  • setting the font-size and line-height to 0 in inline css

Nothing worked.

Side notes:
If there is only one empty table cell in the middle, the rendering is fine. So it seems as if each td only accounts for half a pixel
This is already a simplified example and I cannot change the structure of the table meaning that I have to find a workaround for the rendering problems rather than fixing the rather unpretty coding style unfortunately.

Testing
Here is my testing environment - feel free to play around with it: http://putsmail.com/d58ffa01c4b3e29123baab00754716


Source: (StackOverflow)

Outlook Add-in. Place a form instead message pane and reading pane

Can somebody tell me how to display a form in the area marked red, or at least how this area can be reached from my application. Any help appreciated.

enter image description here


Source: (StackOverflow)

open new Outlook from website, too long mailTo Link, *.eml file bcc field not loaded

I'm trying to open a *.eml file with Microsoft Outlook 2010 and got problems with the bcc field.

Here is my eml file:

To: example@domain.com
Subject: Mail Subject
cc: cc@domain.com
bcc: bcc@domain.com
Content-Type: text/plain
MIME-Version: 1.0
X-Unsent: 1

Mail content

When I open this eml file with Outlook all entries work fine, except bcc. How can i bring the bcc field to work?

Edit

I basicly want the same behavior of a mailto link on a webpage. The user should click on a link and the default mailprogram (which is Outlook in the office where the software is used) should open. mailto links work fine until the link is not longer than about 2000 characters. In my case, the informations that I need to pass to Outlook are much longer than 2000 characters, so I tried to generate an *.eml file which doesn't work as expected.

So what I need:

  • a link similar to a mailto link
  • must work with more than 2000 characters
  • must work in Google Chrome & Outlook 2010

What I got:

  • PHP
  • JavaScript with jQuery

Source: (StackOverflow)