| Code level: intermediate Code area: Basic Outlook Printer Friendly Version | ||
| Title: Process incoming mail with NewMailEx | ||
| Description: NewMailEx in Outlook 2003 and later versions can process nearly all incoming messages. This short sample extracts the date value (no time details) from the Received date and puts in the BillingInformation field, so the user can then group by date on that field. | ||
| Date: 25-Oct-2006 21:35 | ||
| Code level: intermediate | ||
| Code area: Basic Outlook | ||
| Posted by: Sue Mosher | ||
| Body: |
||
| All 25comments |
| Page [ 1 2 3 Next >> ] | ||
|
|
Sue Mosher
25-Oct-2006 21:39
This sample is written for the built-in ThisOutlookSession module in Outlook VBA. For VBA basics, see http://www.outlookcode.com/d/vbabasics.htm This is a somewhat inelegant sample, because it uses the Dim m As MailItem and On Error Resume Next statements to ignore any new items that are not MailItem objects. It also assumes that the user has no accounts that are downloading headers only, and so it doesn't check the DownloadState to see if the full message is available yet. For more on NewMailEx, see http://msdn.microsoft.com/library/en-us/vbaol11/html/olevtNewMailEx_HV01019236.asp |
|
|
|
Edwin Bisek
17-Nov-2008 13:17
Hello Sue, I have been reading a huge number of your forum posts and thank you so much for sharing all this knowledge. I am stuck however on the security prompting for access to the e-mail addresses when trying to access the body of the message. I am following your examples to the letter (cut-and-paste and I still get these darn prompts. I use Outlook 2003 and VBA. Please help. Regards, Edwin |
|
|
|
Edwin Bisek
17-Nov-2008 13:24
Hello Sue, I found another posting on another site, to which you responded. I found out that my system is administrator controlled and thus the prompt is unavoidable. Thanks again, Edwin |
|
|
|
Sue Mosher
17-Nov-2008 15:34
In that scenario, Edwin, you'd have to use one of the other solutions listed at http://www.outlookcode.com/article.aspx?ID=52 such as recoding with Redemption or using one of the utilities. Any of those would require installing third-party software, which your administrator may not allow. |
|
|
|
Jayesh D
16-Dec-2008 04:00
Hi Sue , Edwin I have one querry , I am trying to read the body of mail,including subject, i found the example in help of outlook for reading subject of any incoming mail(ON NewMailEx event), but unable to get the body (content of mail), if you have any idea let me know thanks in advance Jayesh Dulani |
|
|
|
Sue Mosher
16-Dec-2008 08:22
Jayesh, the body of the message is returned by the Body and, in the case of an HTML-format message, HTMLBody properties. The object browser shows you all available properties of the MailItem object. |
|
|
|
roberto
23-Jan-2009 18:03
I need to save excel attachments within incoming mail and import some cells in an access DB. Anybody can halp me ? I'm trying to write a script. Thank you in advance. Roberto |
|
|
|
Sue Mosher
23-Jan-2009 18:23
roberto, to work with the data in an attachment, you first must save it outside Outlook. These samples show various approaches to the task of saving attachments: http://www.fontstuff.com/outlook/oltut01.htm http://www.outlookcode.com/codedetail.aspx?id=70 http://www.outlookcode.com/codedetail.aspx?id=866 http://www.outlookcode.com/codedetail.aspx?id=1494 http://www.slovaktech.com/code_samples.htm#StripAttachments http://www.outlookcode.com/codedetail.aspx?id=1926 Once you've saved the file, it's no longer an Outlook coding issue. You'd use standard Excel techniques to open the file and read its data and ADO to handle the connection with Access. The information on these pages might be useful to you: http://www.outlookcode.com/article.aspx?ID=23 http://www.outlookcode.com/article.aspx?ID=25 but if you have specific questions on the Excel-to-Access part of the project, it's best to ask in a forum for one of those products. |
|
|
|
Alex
19-Feb-2009 13:09
This code has been really useful, how do I use to to populate a custom field called "Case Ref", rather than Billing Information? |
|
|
|
Sue Mosher
24-Feb-2009 16:18
Alex, you would need to add the property to the incoming message through the MailItem.UserProperties.Add method, e.g.: Set prop = m.UserProperties.Add("Case Ref", OlUserPropertyType.olText) prop.Value = "some string value" Please see the Help topic on UserProperties.ADd and http://www.outlookcode.com/article.aspx?ID=38 for more information on working with UserProperties. |
|
| Page [ 1 2 3 Next >> ] | ||
| Post your comment name email |
