Quantcast
Channel: All OutlookCode.com content
Viewing all 871 articles
Browse latest View live

Incoming mail with instant search?

$
0
0
Hello Im relatively new to VBA. However, I would like to write a script for 2010, to read incoming mail's header, body and attachment's content for certain string. and output the mail's name to a text file. I realized that 2010's Instant Search has already the search algorithm i need, are there any way to incorporate that into a script?

Timing The sending of EMAILS

$
0
0
I have written some code to break up an e-mail I receive into parts, then forward those parts as separate e-mails to a text message address (ie, cell phone number). I want to make "sure" the parts are sent in order, even though possibly I cannot control the sms service to send them in the order received. So my intent is to cause outlook to create and send the individual messages, and sit in the outbox for several seconds before being sent. I have tried this numerous ways and someone posted some code to toggle the send/receive control, but it doesn't seem to help. Here is the loop which creates and sends the parts, can someone tell me a way to make outlook pause so they don't all get sent in a blast. For iLoop = 1 To UBound(Arr) If Arr(iLoop) <> "" Then Set NewMessage = Application.CreateItem(olMailItem) NewMessage.To = strDestination NewMessage.Subject = "" NewMessage.Body = Arr(iLoop) ScheduledSendReceiveToggle 'should toggle to disable NewMessage.Send oApp.ActiveExplorer.CommandBars("Standard").Controls("Send/Re&ceive").Execute timernow = Timer Do While Timer - timernow < 5 'pause 5 seconds Loop ScheduledSendReceiveToggle 'should toggle to enable but how to force send / receive? End If Next Sub ScheduledSendReceiveToggle() Dim ctl As Office.CommandBarControl Set ctl = ActiveExplorer.CommandBars.FindControl(, 6867) If ctl.Enabled Then ctl.Execute End If End Sub

How to set outlook to send a message on a timer every hour

$
0
0
Two questions please. 1. Is there a way without a commercial addin to force outlook to run some code once per hour. My code takes care of sending a message to my cell number which tells me that my computer is still connected to Exchange. If I don;t get the text I will know my computer got disconnected. 2. Is there a way I can call Application_Startup() in the ThisOutlookSession module from another Sub in a standard module? The reason is that occasionally my variables lose state. If I could call a Sub in a standard module which in turn calls Application_Startup, then I could re-set Outlook to respond to incoming mail by calling that sub.

How to send emal to an email adress INSIDE a different message

$
0
0
I would like to know how to send a preset email to an adress that is inside an incomming email I am able to get the program to execure the script only if a specific sequence of letters is inside the email but not to get it to sent the email to the adress. I however do not want to reply.

insert text file into BODY of email not as attachment

$
0
0
Previously in Outlook 2003 we were able to use Word VBA to insertfiles into the body of an email. But this was because Outlook used Word as it's editor. Now 2010 doesn't allow this yet I would still like to be able to do this. The VBA i used previously was as follows: It is run from a form (this was controlled by a keyboard shortcut) Global Const varUSERTEXT As String = "w:\zzword97\usertext\" Sub UserText() frmUserText.Show End Sub Sub GeneralUsertextClauses() Dim strfilename As String 'Dim oDoc As Word.Document Dim wd As Word.Application Dim Doc As Word.Document Dim fDialog As FileDialog Dim vrtSelectedItem As Variant Set fDialog = Application.FileDialog(msoFileDialogFilePicker) With fDialog .Title = "Select Text Segment File" .InitialFileName = varUSERTEXT .Filters.Add "Word Documents", "*.doc", 1 .AllowMultiSelect = False If .Show <> -1 Then MsgBox "cancelled by User", , "List Folder Contents" Exit Sub End If strfilename = .SelectedItems(1) End With Selection.InsertFile strfilename, Range:="", ConfirmConversions:=False, link:=False, attachment:=False End Sub Is there anyway to do this in Outlook 2010 it is so useful to us Many thanks for your help Jane

Sender and Date added to Subject line as a rule

$
0
0
Hi all, I will start by saying I am very very new to using scripts and Macros in outlook. What I have so far is a Macro code to add in the current date to the subject line of an email when I select it. I would like to take this further by not only adding the Sender, but use the the entire script as a rule for incoming emails to auto add the sender and date when the email is recieved . Heres what I have for the date script, and Im lost where to go from here. Any help would be greatly appreciated! Sub Test() Dim MItem As MailItem On Error GoTo ExitPoint For Each MItem In ActiveExplorer.Selection MItem.Subject = Date & " " & MItem.Subject Next ExitPoint: End Sub

Moving sleected email to "Completed" folder

$
0
0
On form click, put selected email in appropriate Inbox's Completed Folder

Moving email to correct "Completed" folder when multiple Inboxes and Completed folders exist

$
0
0
We have several Mailboxes open in our Outlook 2007 (an Exchange server is used, but I don't think that matters for this post). Each one has an Inbox, and in the Inbox is a "Completed" folder. So, as an example in our left pane folder list, we would see this (each "Issue" mailbox is the separate outlook account loaded in this Outlook window): Mailbox - MyName Deleted Items Drafts Inbox Issue1 Deleted Items Drafts Inbox WIP Completed Issue2 Deleted Items Drafts Inbox WIP Completed We can have up to 10 of these "Issue" mailboxes. We have a form we use to choose a category of email (this category corresponds with the mailbox names; the choices would be "Issue1", "Issue2", etc. When we choose the catgory (mailbox name) and click a button, we want (among other things that happen and are working OK) the selected email to be moved to the "Completed" folder of that mailbox. For instnace, in my form, when I choose "Issue2" as te category and click the button, the selected email should be moved to the "Completed" folder in the Inbox folder of mailbos "Issue2". Now, this actually works when I have "Issue1" as my category, but for some reason when I choose "Issue2" it does NOT move the email. The code being used is below. I will note that, when it works, in the line: If objFolder.DefaultItemType = olMailItem Then objFolder.DefaultItemType IS set to something. When it does NOT work, floating the mouse over this line in Break mode shows: objFolder.DefaultItemType = <the operation failed> Oddly, it also continues into the Then clause (normally I would expect, if objFolder.DefaultItemType was not set, then the if/then clause would be false. However, the code steps right on into the Then part, as if there was not a problem. I cannot understand why this is not working for ANY choice in the form EXCEPT for "Issue1." Again, when I choose "Issue1", it works. If I choose "Issue2," it does not. The spelling is correct for the mailbox names. There IS a "Completed" folder in the "Inbox" folder of all the mailboxes. Can anyone please help me figure out why this is only working for one of my choices? Code: http://www.outlookcode.com/codedetail.aspx?id=2220

Using .NET to get Internet Headers property from an IMAP MailItem

$
0
0
I apologize if this is a very n00b question. I am trying to get headers from a MailItem in an Outlook Add-in I'm working on. The issue is that if the MailItem is retrieved via IMAP and only it's headers have been downloaded the PropertyAccessor seems to throw an exception where it wants the message to be pulled down from the server before it will return the headers value. I've used OutlookSpy to see it's there via the IMessage view, but cannot seem to get it right using either Redemption, MAPI33 or Helmut's pure .NET code. Would appreciate a point in the right direction. I don't want to mark for download and go that route if possible. Thanks.

Uncheck calendar in current pst and check calendar in opened pst

$
0
0
After opening a second pst file, using vba I would like to turn off (uncheck) the calendar in my main pst file and turn on (check) the calendar in the second pst file. I've looked through the properties of folders but can't find one that looks as if it would activate or deactivate the folder. Can anyone help with this please? Neil

Need a bit of help with handling attachments

$
0
0
Hello, I come to this site in search of an answer that seems to be beyon my reach. I have been requested to create a script that will parse each new email that comes in a specific mailbox and forward those with a specific attachment *name* to another email account. So far, i managed to several examples of code. One of them was supposed to do just that : 'code goes in "ThisOutlookSession" module Private Sub Application_NewMailEx(ByVal EntryIDCollection As String) Dim arr() As String Dim i As Integer Dim ns As Outlook.NameSpace Dim itm As MailItem Dim m As Outlook.MailItem Dim att As Outlook.Attachment On Error Resume Next Set ns = Application.Session arr = Split(EntryIDCollection, ",") For i = 0 To UBound(arr) Set itm = ns.GetItemFromID(arr(i)) If itm.Class = olMail Then Set m = itm If m.Attachments.Count > 0 Then For Each att In m.Attachments If UCase(att.FileName) Like "*REPORT*" Then MoveToFolder m, "MoveTest" Exit For End If Next att End If End If Next Set ns = Nothing Set itm = Nothing Set m = Nothing End Sub Sub MoveToFolder(mItem As MailItem, folderName) '###you need to edit this for your account name### Const mailboxNameString As String = "Mailbox - firstname lastname" Dim olApp As New Outlook.Application Dim olNameSpace As Outlook.NameSpace Dim olDestFolder As Outlook.MAPIFolder Set olNameSpace = olApp.GetNamespace("MAPI") Set olDestFolder = olNameSpace.Folders(mailboxNameString).Folders(folderName) Debug.Print "[" & Date & " " & Time & "] " & _ ": folder = " & folderName & _ "; subject = " & mItem.Subject & "..." mItem.Move olDestFolder End Sub Placing that in ThisOutlookSession plain doesn't work (i updated mailboxnamestring). I don't know what i'm doing wrong - i haven't got any kind of feedback as to where does it hang or if it runs or not. What would i have to modify for this to be able to be saved as a macro/script, so that i can make it part of a rule? what am i doing wrong? Thanks in advance! AP

Accessing actions on other users calendar

$
0
0
Hi, I'm writing an Outlook-Addon for the handling of absences in c#. It is necessary to trap the events for users storing absences on ther users calendars. This does work, if the users open the appointment-form / Inspector. My problem is the action of users with the mouse via contextmenu (delete), or drag 'n' drop (edit) without using an Inspector-Object. That has to happen in addin_startup, I guess This is not trapped right now, as you can see in the code-snippet below OlNs = Globals.ThisAddIn.Application.GetNamespace("MAPI"); olFold = OlNs.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar); Calendarevents = (Outlook.MAPIFolderEvents_12_Event)olFold; CalendarItems = olFold.Items; CalendarItems.ItemAdd += new Outlook.ItemsEvents_ItemAddEventHandler(CalendarItems_ItemAdd); CalendarItems.ItemChange += new Outlook.ItemsEvents_ItemChangeEventHandler(CalendarItems_ItemChange); CalendarItems.ItemRemove += new Outlook.ItemsEvents_ItemRemoveEventHandler(CalendarItems_ItemRemove); Calendarevents.BeforeItemMove += new Outlook.MAPIFolderEvents_12_BeforeItemMoveEventHandler(Calendarevents_BeforeItemMove); As you can see, every eventhandler is based on the calendar of the current user. So everything, that happens on a calendar of another user, is not trapped. Is there a way to handle actions of users on calendars of other users?

Problem adding Recipients while using redemption?

$
0
0
I have code using redemption that displays the send email dialog from an external application. I then use the ItemEvents.Send to add additional information to email. For each example I want to add myself to the cc of every email sent from this screen that prompts the users with the send email dialog. Solution 1 works only if i set CC in the code that is displaying the dialog to begin with. If i run it from the ItemEvents.Send i get an error the says "This Operation Failed" Solution 2 works perfectly how I want it to except that the Outlook Security Dialog pops up. Solution 3 is how I would do it with redemption. However it sends the message fine but never adds the cc recipient to the email nor includes them when it is sent out. So how can I use redemption for this? PROCEDURE ItemEvents.Send: DEFINE INPUT-OUTPUT PARAMETER oCancel AS LOGICAL. IF oCancel = FALSE THEN DO: FIND CURRENT ttETPQ NO-LOCK NO-ERROR. IF AVAIL ttETPQ THEN DO: RUN createNote(INPUT STRING(ttETPQ.etId), INPUT "EmpTrackerAnswer", INPUT ttETPQ.etEmployeeId, INPUT hSafeItem:TO, INPUT hSafeItem:Body). /* SOLUTION 1 */ /* Doesn't work either and get 'This Operation Failed' pop up */ /* hSafeItem:CC = "dpipes@blah.com". */ /* SOLUTION 2 */ /* Outlook works but prompted for security dialog */ /* DEFINE VARIABLE hRecipients AS COM-HANDLE NO-UNDO. hRecipients = hMail:Recipients:ADD("dpipes@blah.com"). hRecipients:resolve. IF hRecipients:resolved THEN hRecipients:TYPE = 2. */ /* SOLUTION 3 */ /* DEFINE VARIABLE hRecipients AS COM-HANDLE NO-UNDO. hRecipients = hSafeItem:Recipients:ADD("dpipes@blah.com"). hRecipients:resolve(TRUE). IF hRecipients:resolved THEN hRecipients:TYPE = 2. */ END. END. END PROCEDURE.

Cannot publish the form. The form cannot be installed because you do not have owner permissions

$
0
0
Im running Outlook client 2010 and I want to publish a Form to the Organisational Forms Library on Exchange Server 2003 and I get the following error message: "Cannot publish the form. The form cannot be installed because you do not have owner permissions". I have searched for this in most of the forums and I cant seem to get the solution. This is a custom Outlook Survey Form that I downloaded from www.outlookcode.com. Please note that I have the owner permission for the folder that I created using the proper and reliable step by step instructions for creating and Organisational Folder (http://support.microsoft.com/?kbid=244591). I have tried the following which also failed: 1. Disabling Cache mode 2. Checked the permission and confirmed that they are OK. Looking forward for you help. Thank you

Upgraded from Outlook 2007 to 2010 & am getting an error ...

$
0
0
Hi there, I have a small program that checks my E:Mails & moves them to specific folders, but after an upgrade to Outlook 2010 it no longer works. I thought I probably needed to add a Reference (how do you tell which one ?!?) but I found a Blog suggesting that this may be due to a change in the way Outlook 2010 works. I am not an expert in VBA by any means, so if somebody could help I would appreciate it immensely. This is the code ... [code]Function OpenMAPIFolder(szPath) 'Pass a parameter to this module, in the following format, to set the rightmost Folder 'as the object, or live, Folder ... "\Gary\Kickabout\Attachments" Dim app, ns, flr, szDir, i Set flr = Nothing Set app = CreateObject("Outlook.Application") If Left(szPath, Len("\")) = "\" Then szPath = Mid(szPath, Len("\") + 1) Else Set flr = app.ActiveExplorer.CurrentFolder End If While szPath <> "" i = InStr(szPath, "\") If i Then szDir = Left(szPath, i - 1) szPath = Mid(szPath, i + Len("\")) Else szDir = szPath szPath = "" End If If IsNothing(flr) Then Set ns = app.GetNamespace("MAPI") Set flr = ns.Folders(szDir) <<< The Error occurs on this line Else Set flr = flr.Folders(szDir) End If Wend Set OpenMAPIFolder = flr End Function[/code] ... and this is the Error ... "Run Time Error '-2147221233 (8004010f)': The attempted operation failed. An object could not be found."

Copy receive date for incomming messages

$
0
0
Creating a hotkey to copy the receive date

Delete the top row of an email message automatically

$
0
0
Hi there, I am trying to automatically delete the top row of any newly created message and the code I am using is; objolMailItem.Body = Replace (objolMailItem.Body, Left (objolMailItem.Body, Loc),"") where Loc points to the 1st vbCrLf of the message. The code works ok except that it takes away all the formatting in the body of the message. Am I doing something wrong and can someone please help, Thanks in advance Jon,

Outlook 2000 - Duplicate Emails (Code Request)

$
0
0
Hello, I am looking for code that will allow Outlook to count duplicate emails and if the duplicates are sent ~5 minutes apart generate a pop-up or post a canned email template to a distribution list. Any help on this would be fantastic! Thanks in advance. Respectfully, Craig

If a folder exists, Outlook (Vbscript)

$
0
0
Hi all I'm currently writing a script to move emails older than a set date to a non-default folder in outlook. This is done but I am having trouble with a simpler issue. I need my program to see if a folder exist and then if the folder doesn't exist create one. So far I have written (cut and paste from other peoples) a program that counts through the folders in outlook and If the folder is found then message boxes a reply and if not it should create a new one of the same name. This is not working as I think the is something wrong with the IF, Then ... Else statement? the program trys to create the folder regardless of whether it exists or not and if it does exist I get a 'Cannot create the folder. Here's the code: Const Inbox = 6 ' Inbox Items folder Set objOutlook = CreateObject( "Outlook.Application" ) Set objNameSpace = objOutlook.GetNamespace( "MAPI" ) Set objFolder = objNameSpace.GetDefaultFolder( Inbox ) 'sets objFolder to the Inbox for it's reference Set objMyfolder = objFolder.Parent 'Set objMyfolder as the Inbox's parent folder For i = 1 To objMyfolder.Folders.Count If objMyfolder.Folders.Item(i).Name = "My New Folder" Then MsgBox "exists" Else objNewFolder = objMyfolder.Folders.Add("My New Folder") End If next

Could not load file or assembly

$
0
0
I have created an .exe for outlook contacts plugin in vb.net. But i have developed it in outlook 2010 environment so now the code doesn't works in outlook 2007 version. It throws me the "couldn't load file or assembly microsoft.office.interop.outlook". I have find out that it is searching the references of outlook 2010 packages like this "Microsoft.Office.Interop.Outlook, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" but the machine has 2007 and this packages is not available in that machine. anyone please guide me to get out of this error . Thanks in advance!
Viewing all 871 articles
Browse latest View live