Quantcast
Channel: Outlook for Developers forum
Viewing all 6421 articles
Browse latest View live

Mail.Save takes a long time

$
0
0

Hello,

I am developing an Outlook plugin, and ran into some serious issues.

My design is that I listen to NewMailEx event, extract a few mail properties and add my own user property. This all works fine until I saw when there are bulk emails (e.g Outlook was closed for several hours), the event does not arrive for many emails. So, I implemented a scanner that after sync event goes over emails and adds my property to the ones that don't have it.

Here is what I got:

1. I could not run the scanner in a background thread as I saw there is a difficulty to access the model from bg thread

2. When I go over a lot of emails and save them 1 by 1, it is very heavy on the I/O and Outlook is frozen because of that. Save is going to the pst file and is slow. I called System.Windows.Forms.Application.DoEvents() every time, but it did not help.

Please advise


GetFolderFromID returns 0x8004011D instead of prompting for password

$
0
0

With Outlook 2013, when Outlook is not running and my program calls GetFolderFromID for a folder in a password-protected PST, it fails with MAPI_E_FAILONEPROVIDER (0x8004011D), whereas Outlook 2010 and earlier would prompt the user for the password. Is there a way to get Outlook 2013 to prompt for the password?

This Windows Host Script reproduces the problem:

' ---- cut here -----

'   This script demonstrates the problem where Outlook 2013 returns
'   MAPI_E_FAILONEPROVIDER (0x8004011D) when GetFolderFromID is
'   called with the ID of a password-protected folder. Previous
'   versions of Outlook prompted for the password.

'   Before running this script, create a password-protected PST
'   containing a folder. Do not save the password in your password
'   list.

'   Then, with Outlook not running:

'   Run the script. The first time you run it, the script displays
'   Outlook's "Select Folder" dialog. Choose the password-protected
'   folder you created. (Outlook will prompt you for the password.)

'   Run the script again. The second and subsequent times, the script
'   tries to reopen the folder you selected. It displays two messages
'   with the folder's EntryID and StoreID, then displays the
'   folder.

'   With Outlook 2010, when Outlook is not open, you are prompted to
'   enter the password and the operation succeeds. With Outlook 2013,
'   you are not prompted for the password and the operation fails with
'   0x8004011D.

'   To reset the script delete %TEMP%\IDs.txt

Const ForReading = 1, ForWriting = 2
Const TemporaryFolder = 2

Dim folder
Dim entryID
Dim storeID
Dim filename
Dim fs, f

Set outlook = CreateObject("Outlook.Application")
Set fs = CreateObject("Scripting.FileSystemObject")

folderIDs = fs.GetSpecialFolder(TemporaryFolder).Path & "\IDs.txt"
If fs.FileExists(folderIDs) Then
   Set f = fs.OpenTextFile(folderIDs, ForReading)
   entryID = f.ReadLine
   storeID = f.ReadLine
   f.Close
   Wscript.Echo "EntryID:" & vbCRLF & entryID
   Wscript.Echo "StoreID:" & vbCRLF & storeID
   Set folder = outlook.Session.GetFolderFromID(entryID, storeID)
Else
   Set folder = outlook.GetNamespace("MAPI").PickFolder
   Set f = fs.OpenTextFile(folderIDs, ForWriting, True)
   f.WriteLine folder.EntryID
   f.WriteLine folder.StoreID
   f.Close
End If

folder.Display


Wrong signature applied when using multiple Outlook accounts

$
0
0

I am using Outlook 2010. I have 2 exchange accounts. My "main" personal one and then a 'shared' one.

I have a default signature file for each. When working directly in Outlook, when I create a new email, the correct signature is provided (sig1 for account1 and sig2 for account2).

However, when I create a new message programmatically, the signature file for my "personal" account (sig1) is added to the Body of the message when I set the SendUsingAccount field of the mail object to the "shared" account (account2). I know I have the account properly set, as when I send the mail, it is correctly sent from the "shared" mailbox.

Could you explain this to me please? 

Code snippet below:

         

Set olApp = CreateObject("Outlook.Application")		' Create Outlook object    
For Each olAccount In olApp.Session.Accounts			' Find the Shared account in the list        
   If olAccount.SmtpAddress = SenderAddress Then     GotIt = 1            
      Exit For        
   End If   
Next   

Dim olMail As Outlook.MailItem   
Set olMail = olApp.CreateItem(olMailItem)   ' Body is empty at this point   
olMail.SendUsingAccount = olAccount   

' Body now contains the signature of my "personal" account, *not* the account specified by olAccount.

Outlook 2007 Export and Import Modules and Userforms

$
0
0
In the normal area I have many many modules and userforms.....is  there way that when I export them so I can inport them to my other computer, I can select a list of them to export and then import, rather than do it each one as a single export import?

Recommend Outlook 2013 Book and Classes for Developers

$
0
0

Can someone recommend an Outlook 2013 Book and/or Classes for Developers?

We have been developing Outlook Add-ins for Outlook 2010 without formal training, I would like to get formal training for Outlook 2013.

Any help would be great....

Outlook 2010 - MeetingItem's Flag Status property

$
0
0

How to retrieve the Flag status of a Meeting / Appointment Item.

I tried using the MAPI Proptag - "http://schemas.microsoft.com/mapi/proptag/0x10900003".

It is working fine with MailItem 

Here is the piece of code that i am trying out in my Add-In.

int FlagStatus = Meetingitem.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x10900003");
in this code, the FlagStatus variable's value is always 0, even after setting the flag for the selectedMeetingitem


Configuration:

Outlook 2010, Windows 7 64bit, Visual Studio 2010, Exchange Server 2013.

saving mail from outlook

$
0
0

Hi. I'm new to COM/ATL development . I've build a COM add-in for Outlook 2010, using this tutorial as main source of information. http://msdn.microsoft.com/en-us/library/ee941475%28v=office.14%29.aspx.

When I click a button(that I specifically asign) , I want to save the body of emails(all the mails from inbox) in a text file . Can somebody give me an ideea how do i that? Any code snippet( in C++ ) would be great.

Thanks in advance.

edit:

i wrote a small piece of code to get the number of emails from inbox. Now i just need to get the body of emails . Any suggestion how i do that?

         _ApplicationPtr pApp;

        _NameSpacePtr pNamespace;
        pApp->GetNamespace(L"MAPI");
        MAPIFolderPtr InboxFolder = pNamespace->GetDefaultFolder(olFolderInbox);
        _ItemsPtr mails = InboxFolder->Items;
        const long count = mails->GetCount();

        for(long i=1;i<=count;i++)

          {

          }

Reading contacts from Outlook 2013 shared folder

$
0
0

Hi all,

A year ago I developed an Access 2010 app which would read contacts from a shared Outlook 2010 contacts folder and write them to a table (for performing SQL queries elsewhere in the app).

This is the code:

Set olApp = CreateObject("Outlook.Application")
Set olNs = olApp.GetNamespace("MAPI")
Set Fldr = olNs.Folders("Public Folders - " & olApp.Session.CurrentUser.AddressEntry.GetExchangeUser.PrimarySmtpAddress).Folders("Favorites").Folders("Acme Shared Contacts")

For Each olCi In Fldr.Items
    coname = olCi.CompanyName
    email = olCi.Email1Address
    FirstName = olCi.FirstName
    LastName = olCi.LastName

    DoCmd.SetWarnings False
    DoCmd.RunSQL "INSERT INTO Contacts ([Company], [E-mail address], [First], [Last]) VALUES ('" & coname & "', '" & email & "', '" & FirstName & "', '" & LastName & "');"
    DoCmd.SetWarnings True
Next olCi

The client has now upgraded to Access 2013 and Outlook 2013, AND moved the location of the folders.  The new folder location looks like "Other Contacts \ Shared Contacts" (i.e. a folder called "Shared Contacts" under "Other Contacts".)  The properties of that folder are "\\Public Folders - username@acmie.com"

I tried simply changing 

Set Fldr = olNs.Folders("Public Folders - " & olApp.Session.CurrentUser.AddressEntry.GetExchangeUser.PrimarySmtpAddress).Folders("Favorites").Folders("Acme Shared Contacts")

To

Set Fldr = olNs.Folders("Public Folders - " & olApp.Session.CurrentUser.AddressEntry.GetExchangeUser.PrimarySmtpAddress).Folders("Shared Contacts").Folders("Other Contacts")

But get the error:

"The attempted operation failed.  An object could not be found"

Any ideas?



Deathly-slow code reading Outlook 2013 contact items from Exchange Public Folder

$
0
0

Hi all,

I am using the following code to iterate through the contacts in a shared Outlook 2013 folder and inert them into an Access table.  The following code is in the Access 2013 VBA project:

Set olNs = olApp.GetNamespace("MAPI")
'Set Fldr = olNs.Folders("Outlook Data File").Folders("Contacts")
Set Fldr = olNs.Folders("Public Folders - " & olApp.Session.CurrentUser.AddressEntry.GetExchangeUser.PrimarySmtpAddress).Folders("All Public Folders").Folders("Shared Contacts")

For Each olCi In Fldr.Items

    If (TypeName(olCi) = "ContactItem") Then

    coname = olCi.CompanyName
    email = olCi.Email1Address
    FirstName = olCi.FirstName
    LastName = olCi.LastName
   
    DoCmd.SetWarnings False
    DoCmd.RunSQL "INSERT INTO Contacts ([Company], [E-mail address], [First], [Last]) VALUES ('" & coname & "', '" & email & "', '" & FirstName & "', '" & LastName & "');"
    DoCmd.SetWarnings True
    End If

Next olCi

This seems to work fine when I test it on my local machine with approx 2500 contacts in my local Outlook Data File.

However, when I run the same code against a shared Exchange Public Folder with approx 7400 contacts, the code appears to grind to a halt, although it does complete after about 20 minutes!

Does there seem to be anything in my code that anyone can spot that may be horribly inefficient?

Thanking you in advance!

Rob


Rob

VBScript - Managing recipients from GetSelectNamesDialog

$
0
0

I am very new to custom Outlook forms and VBScript. My form has 4 buttons to select 4 people from the GAL who serve in different roles. I would like to copy these selections to the "To" field in the Message tab so that the form is sent to all of them.

So far I have been able to populate 4 custom fields with the following function, then use the Item_PropertyChange method to populate the To field with a concatenation of these fields separated by semi-colons.

    Function GetOneNameViaCDO()
        ' start CDO session
        Set objSession = CreateObject("Outlook.Application")
        objSession.GetNamespace("MAPI").Logon , , False, False

        set oDialog = Application.Session.GetSelectNamesDialog

        With oDialog
            .AllowMultipleSelection = false
             .SetDefaultDisplayMode 5
             .Caption = "Select Project Manager"
            .ToLabel = "Project Manager:"
            .Display

            If .Recipients.Count > 0 Then
                Set GetOneNameViaCDO= .Recipients.Item(1)
            End If
        End With
    End Function

Unfortunately, this just puts the "text" name of the recipients in the To field that have to be resolved before the message can be sent. (I'm getting strange errors when that happens, but I'm hoping they will go away when I figure out how to do this correctly.)

So my question is: Is there a way to save the actual "recipient" objects in custom fields, then add them to the To field before sending? If not, how would I save the the email addresses from the recipients in custom fields and copy those to the To field so that they are resolved automatically before sending?

Thanks!

Get all Distribution List Owners - Outlook 2010

$
0
0

Greetings,

I am currently looking for a way to get the owners of a distribution list without using OWA. The platform is Exchange 2010, and I am able to use EWS to get the member and primary owner, but not the additional owners. I currently use an outlook plugin in C# that gets this information (primary owner), but doesn't display all the owners of the distribution list. Does anyone know of a way to get this information programmatically without using OWA? I need to query about 190 Lists. I also need to mention I do not have access to the exchange management console, the only resources that I have is OWA and Outlook 2010. Eventually, we want to give this program to end users to use to manage the List themselves. Our exchange server uses a proxy, featuring SSL and Async. The only thing I can think of at this point is Screen Scrapping the OWA screen, but that is a last resort at this point. Our AD controllers don't house the Distro List, our exchange servers are housed at another location that we can not manage or access. I doubt we even have access to LDAP to query the information, although I can access the server using  mfcmapi tool. Anyone have any ideas? Thanks!

D Harrington


Dimitri J Harrington

VSTO - AddIn for Office Outlook 2010 - Sending MailItem

$
0
0

Hi,

I got a problem. Let me give a short explanation.

I delevoped a addin with a usercontrol displayed right side of Outlook. There are some input buttons and a "SEND" button on the usercontrol. The idea is that a user selects (just clicks) on a mail in the explorer, inserting some values in the usercontrol and press the send button on the usercontrol. The mail selected should be send to a selected user in the usercontrol (dropdown) and set the subject field to a value that is inserted in a textbox in the usercontrol. The mail should be send and the original mail should still be in the inbox. If a use this code:

Outlook.MailItem mailItem = null;

Outlook._MailItem tobesent = null;

object item = _currentExplorer.Selection[1];

if(item is Outlook.MailItem)

{

    mailItem = item as Outlook.MailItem;

tobesent = mailItem.Copy;

tobesent.Subject = textbox.text;

tobesent.To = ddl_toadress.SelectedItem;

tobesent.Send();

}

This is also fine because I want the Body be unchanged. Thats why i use the Copy method. I only change Subject and to address and sending the mail.

The problem is that i get the error ->

You do not have the permission to send the message on behalf of the specified user.

-----------------------------------------------------------------------------------------------------------

My second idea was:

Create a new mailitem and copy the contents from the existing mail to the new created mail.

mailitem = item as Outlook.MailItem;

tobesent = (Outlook.MailItem)Globals.ThisAddin.Application.CreateItem(Outlook.OlItemType.olMailItem);

tobesent.Subject = textbox.text;

tobesent.To = ddl_toadress.SelectedItem;

tobesent.Display(false);

tobesent.BodyFormat = Outlook.OlBodyFormat.olFormatHTML;

tobesent.HTMLBody = mailItem.HTMLBody;

tobesent.Importance = Outlook.OlImportance.olImportanceNormal;

tobesent.Send();

Tis works fine, it is possible to send the new mail. But the problem here is:

The body from the original mail is copied. The text and links etc are copied. But the embedded images are not.

So if I just copy the original mail I "cant sent in behalf of another person" and if I create a new mail with copying the contents from the original mail, then the embedded images are not following with:

tobesent.HTMLBody = mailItem.HTMLBody;

REGARDING

ERKAN/DENMARK

How to avoid Select Profile PopUp that comes when creating Outlook.Application object ?

$
0
0

Hi all,

          I am using Outlook Object library for Getting Items within PST file.When ever i am trying to create Outlook.Application

Outlook internally prompting a select profile popup in multi profile Configured  outlook .I handled this scenario by editing registry value that found in @"Software\Microsoft\Exchange\Client\Options\PickLogonProfile to 0. But one of my friend told me registry change is not right thing to do. I also used namespace.Logon methos but still issue persist. Is there any other way to handle the scenario ? please advice.

Thanks

***Hemant    


H.S.Navarkar

Outlook Plugin - Issue with Outlook 2010 - Showing Non-recurrent Meetings as recurrent

$
0
0

Hi All,

We have created a Outlook Plugin which retrieves Meeting details when we click on that meeting.

We have a condition to check for recurrency:
AppointmentItem appointment_ = app.ActiveExplorer().Selection[1] as AppointmentItem;

if(appointment_.IsRecurring) //Condition to check if the meeting is recurring.

This property works fine in 2003 for shared calenders and personal calenders, but in Outlook 2010 for Shared Calender it shows recurrent true even for non-recurrent meetings/appointments.

Is it some defect with Microsoft.Office.Interop.Outlook (Ver 12.0.0.0).

Please help us resolving this issue or any workaround for the same.

Thanks !



Don't understand what Table.GetNextRow returns from Contacts folder

$
0
0

Hi all,

For the purposes of efficiency, I am trying to convert some code which reads through an Outlook Contacts folder and inserts the results into a SQL table.  I was using Folder.Items to iterate through the contacts like so...

For Each olCi In Fldr.Items

    If (TypeName(olCi) = "ContactItem") Then

    coname = olCi.CompanyName
    email = olCi.Email1Address
    FirstName = olCi.FirstName
    LastName = olCi.LastName
    
    DoCmd.SetWarnings False
    DoCmd.RunSQL "INSERT INTO Contacts ([Company], [E-mail address], [First], [Last]) VALUES ('" & coname & "', '" & email & "', '" & FirstName & "', '" & LastName & "');"
    DoCmd.SetWarnings True
    End If

Next olCi

I have now managed to read the same contacts folder into an Outlook.Table, and then iterate through the Rows like so:

Dim tblContacts As Outlook.Table
Dim rowContact As Outlook.Row

Set tblContacts = Fldr.GetTable

tblContacts.MoveToStart

While Not tblContacts.EndOfTable
    Set rowContact = tblContacts.GetNextRow()
Wend

When I write out the values held in rowContact to a message box I get this:

So I'm not getting the actual email address.  Is the email address somehow encoded in field 1 above?  If that's the case, how do I decode it?  Or am I doing this wrong?

Thanks in advance!


Rob


Failing to load an outlook addin in Office 2013, becomes inactive every time the outlook is closed and opened.

$
0
0

The outlook addin is failing to load in outlook 2013 with an exception "Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 8000ffff Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))." when trying to create an Microsoft.Office.Interop.Outlook.Application object and goes to inactive state.

If we enable it manually, the addin is getting loaded and working fine. But if we close the outlook and open again, the addin would have become inactive.

The same addin works fine in Outlook 2010 and outlook 2007.

Can  you please help to relsove this issue.

Outlook not showing changes made to properties changed through the PropertyAccessor object.

$
0
0

I am using Outlook 2007 and there is an exchange behind it.  I am able to successfully encrypt and decrypt emails by changing the

PR_SECURITY_FLAGS

Getting them like so

Dim oProp AsLongDim oPropAcc As Outlook.PropertyAccessor =Nothing oPropAcc = mayMailItem.PropertyAccessor oProp =CLng(oPropAcc.GetProperty(PR_SECURITY_FLAGS))


Then setting them to 1 to be encrypted and to 0 to be decrypted like so:

oPropAcc.SetProperty(PR_SECURITY_FLAGS, 1)

Pretty simple but I believe largely unwritten or unsupported.

I end by calling save on the MailItem.

One thing I have noticed though is that if I do this to a MailItem (ie. either encrypt or decrypt) and then I try to reverse it.  The property is changed but Outlook does not show it as being changed. So those steps would be.

1. MailItem is Encrypted

2. Decrypt MailItem by changing the PR_SECURITY_FLAGS to 0

3. Save MailItem

4. Outlook shows it now as not encrypted.

5. Encrypt Mailitem by changing the PR_SECURITY_FLAGS to 1

6. Save MailItem

7. Outlook does not now show it as Encrypted. But the PR_SECURITY_FLAGS remains 1.

I am testing this with a small Visual Studio project and if I stop the propject and then run it again, meaning that a new object is created for Outlook / Selection / MailItem then normally the email above which shows as not encrypted now has a PR_SECURITY_FLAGS of 0 again and can now be encrypted.

I know that Outlook has for encrypted messages "two messages" one that is not encrypted and one that is encrypted. So is this an Object thing where I need to release some or all of my objects and start again? Is this a timing thing where Outlook needs to reflect the changes - for example create this fake message etc?

What is happening here.


Outlook 2013 VSTO .... Custom button in reading pane?

$
0
0

Hi,

In Outlook 2013's reading pane, we got the new quick ... REPLY, REPLY ALL and FORWARD. Is it possible to to add a custom button next to "FORWARD" (indicated by the red arrow here)...

?

Thanks!

Mojo

enable Categories in IMAP account

$
0
0

Hi,

Iit seems impossible to categorize e-mails in Microsoft Outlook when using IMAP accoounts. Am I missing something ? Is it something definitely impossible or is there a way to enable it ? How ?

Nicolas

(Windows 7 64 bit, Office Professionnal  2010))

Outlook external pictures not displayed, even if I say yes to Automatic Pictures Download dialog.

$
0
0


Hi,

We have a dialog that hosts browser control to display HTML email messages. The dialog also has reply/forward buttons and the dialog is shown from an Outlook add-in.

When the user clicks on reply/forward, we retrieve reply-action from mailItem.Actions, execute the action, and use the returning mailItem to display the reply-inspector. 

It all works fine. Except that when HTML message has external images i.e. images which are hosted elsewhere on the web, and are referenced in html. 

I know there is a setting in Outlook to allow Automatic Download of pictures. And if I turn that settings OFF, all works fine. 

But with that setting ON, when I hit reply button, I get "Automatic Pictures Download" dialog, telling me that email-message contains external content and asking me if I want to download external content. When I press 'Yes', it doesnt download the images, and images appear as white-boxes. 

However if I hit reply from within Outlook, and press 'Yes' on the same dialog, it does download the images and shows them fine.

Why it doesnt download the pictures when Reply-action is executed from code?

To prove the point that there is nothing wrong with our workflow, I have tried to do the same thing using VBA(Outlook), and it is showing the same behaviour i.e. not showing the pictures when I press Yes. 

VBA code:

Sub TestReply()

    Dim oApp As New Outlook.Application
    Dim oExp As Outlook.Explorer
    Dim oSel As Outlook.Selection   ' You need a selection object for getting the selection.
    Dim oItem As Object             ' You don't know the type yet.
    Dim mailItem As Outlook.mailItem
    Dim replyItem As Outlook.mailItem
    Dim act As Outlook.Action
    
    Set oExp = oApp.ActiveExplorer  ' Get the ActiveExplorer.
    Set oSel = oExp.Selection       ' Get the selection.
    
    
    For i = 1 To oSel.Count         ' Loop through all the currently .selected items
        
        Set oItem = oSel.Item(i)    ' Get a selected item.
        Set mailItem = oItem        ' Assign it to a MailItem object
          
        Set act = mailItem.Actions(1) ' 1 is reply-action
        Set replyItem = act.Execute() ' Exec the action and get reponse mail-item object
        

        'Set replyItem = mailItem.Reply()
        
        replyItem.Display False     ' Display the reply inspector
        
    Next i

End Sub

Also, on a similar note, if I click the banner showing in Outlook message-preview to download external pictures, and then hit 'Reply' on Outlook toolbar, it doesnt ask to download external images, as it has already downloaded them. 

When I display the same email-message in my dialog-browser-control, I display the external images, regardless of Outlook settings. But when I hit Reply on my dialog, I get this dialog. Is there a way to tell Outlook that I have downloaded the images already and this is the location, so that images are displayed normally?

I appreciate your time and help.

Regards,

Muhammad.


Viewing all 6421 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>