![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
Can anyone provide me with code for switching/toggle new emails from HTML
to Plain text? The faxserver use we can only have plain text messages. For normal emails, we use HTML so I need to toggle back afterwards. Thx for help Mats |
Ads |
#2
|
|||
|
|||
![]()
When the item opens you can set its BodyFormat property. You would set that
to OlBodyFormat.olFormatPlain. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "Mats Samson" wrote in message ... Can anyone provide me with code for switching/toggle new emails from HTML to Plain text? The faxserver use we can only have plain text messages. For normal emails, we use HTML so I need to toggle back afterwards. Thx for help Mats |
#3
|
|||
|
|||
![]()
Thanks Ken,
but I'm fairly unfamiliar with Outlook programming, usually I work with Excel and I know there are special arguments etc that have to be set before Outlook cooperates with you, so..... I would appreciate if you can give me a code example? Cheers Mats "Ken Slovak - [MVP - Outlook]" wrote: When the item opens you can set its BodyFormat property. You would set that to OlBodyFormat.olFormatPlain. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "Mats Samson" wrote in message ... Can anyone provide me with code for switching/toggle new emails from HTML to Plain text? The faxserver use we can only have plain text messages. For normal emails, we use HTML so I need to toggle back afterwards. Thx for help Mats |
#4
|
|||
|
|||
![]()
You will obviously need a reference to Outlook in your VBA project. Then in
a code module something like this: ' Module level code Dim WithEvents colInsp As Outlook.Inspectors Dim WithEvents oInsp As Outlook.Inspector Dim oApp As Outlook.Application Dim oNS As Outlook.NameSpace Dim blnFirstActivate As Boolean Sub SetThingsUp() Set oApp = CreateObject("Outlook.Application") Set oNS = oApp.GetNameSpace("MAPI") oNS.Logon "", "", False, False Set colInsp = oApp.Inspectors End Sub Sub colInsp_NewInspector(Inspector As Inspector) If (Inspector.CurrentItem.Class = olMail) Then blnFirstActivate = False Set oInsp = Inspector End If End Sub Sub oInsp.Activate() If (Not blnFirstActivate) Then blnFirstActivate = True If (oInsp.CurrentItem.BodyFormat = olFormatHTML) Then oInsp.CurrentItem.BodyFormat = olFormatPlain End If End If End Sub -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "Mats Samson" wrote in message ... Thanks Ken, but I'm fairly unfamiliar with Outlook programming, usually I work with Excel and I know there are special arguments etc that have to be set before Outlook cooperates with you, so..... I would appreciate if you can give me a code example? Cheers Mats |
#5
|
|||
|
|||
![]()
Ken,
I find the code confusing! The WithEvents doesn't fit in to a Module, they seem to fit into a ThisOutlookSession!?! If I run it from there I get compile error in the "Sub colInsp_NewInspector(Inspector As Inspector), not matching description or having the same name. Furthermore the Sub oInsp.Activate() must be oInsp_Activate, right? The best solution would be if I can attach the code to a toolbar button so when I want to send a fax, I press the button and I get a new plain text message. Regards Mats "Ken Slovak - [MVP - Outlook]" wrote: You will obviously need a reference to Outlook in your VBA project. Then in a code module something like this: ' Module level code Dim WithEvents colInsp As Outlook.Inspectors Dim WithEvents oInsp As Outlook.Inspector Dim oApp As Outlook.Application Dim oNS As Outlook.NameSpace Dim blnFirstActivate As Boolean Sub SetThingsUp() Set oApp = CreateObject("Outlook.Application") Set oNS = oApp.GetNameSpace("MAPI") oNS.Logon "", "", False, False Set colInsp = oApp.Inspectors End Sub Sub colInsp_NewInspector(Inspector As Inspector) If (Inspector.CurrentItem.Class = olMail) Then blnFirstActivate = False Set oInsp = Inspector End If End Sub Sub oInsp.Activate() If (Not blnFirstActivate) Then blnFirstActivate = True If (oInsp.CurrentItem.BodyFormat = olFormatHTML) Then oInsp.CurrentItem.BodyFormat = olFormatPlain End If End If End Sub -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "Mats Samson" wrote in message ... Thanks Ken, but I'm fairly unfamiliar with Outlook programming, usually I work with Excel and I know there are special arguments etc that have to be set before Outlook cooperates with you, so..... I would appreciate if you can give me a code example? Cheers Mats |
#6
|
|||
|
|||
![]()
My error there in the instructions, the WithEvents declarations and event
handlers should be in a class (which could be ThisOutlookSession), and yes the Activate() event should be as you mention for an event signature. If you want this to run on demand the macro can be much simpler and would be in either a code module or ThisOutlookSession: Sub ChangeFormat() Application.ActiveInspector.CurrentItem.BodyFormat = olFormatPlain End Sub However, you can just use the format changing menu commands in that case and not bother with a macro. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "Mats Samson" wrote in message news ![]() Ken, I find the code confusing! The WithEvents doesn't fit in to a Module, they seem to fit into a ThisOutlookSession!?! If I run it from there I get compile error in the "Sub colInsp_NewInspector(Inspector As Inspector), not matching description or having the same name. Furthermore the Sub oInsp.Activate() must be oInsp_Activate, right? The best solution would be if I can attach the code to a toolbar button so when I want to send a fax, I press the button and I get a new plain text message. Regards Mats |
#7
|
|||
|
|||
![]()
Thank you Ken,
your last proposal was in fact the simplest solution, I had overlooked the toolbar option to switch between different formats AFTER starting a new mail. I thought it had to be done prior pushing the New button. Thanks anyway for assistance! Mats "Ken Slovak - [MVP - Outlook]" wrote: My error there in the instructions, the WithEvents declarations and event handlers should be in a class (which could be ThisOutlookSession), and yes the Activate() event should be as you mention for an event signature. If you want this to run on demand the macro can be much simpler and would be in either a code module or ThisOutlookSession: Sub ChangeFormat() Application.ActiveInspector.CurrentItem.BodyFormat = olFormatPlain End Sub However, you can just use the format changing menu commands in that case and not bother with a macro. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "Mats Samson" wrote in message news ![]() Ken, I find the code confusing! The WithEvents doesn't fit in to a Module, they seem to fit into a ThisOutlookSession!?! If I run it from there I get compile error in the "Sub colInsp_NewInspector(Inspector As Inspector), not matching description or having the same name. Furthermore the Sub oInsp.Activate() must be oInsp_Activate, right? The best solution would be if I can attach the code to a toolbar button so when I want to send a fax, I press the button and I get a new plain text message. Regards Mats |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
E-mail are Unreadable Format | Bala Krishna | Outlook and VBA | 1 | October 7th 08 02:13 AM |
How to switch between different e-mail accounts in Outlook 2007? | Edgarki | Outlook - General Queries | 4 | August 25th 07 06:45 PM |
Mail Merge - Format/Send Text and HTML Format | srm | Outlook - General Queries | 0 | January 17th 07 07:15 PM |
Switch to Outlook from Netscape mail | Thor | Outlook - General Queries | 1 | October 10th 06 11:01 PM |
e-mail format | cindycarr | Outlook - Installation | 1 | March 16th 06 10:27 AM |