A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Switch Mail format



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old July 6th 09, 12:20 PM posted to microsoft.public.outlook.program_vba
Mats Samson
external usenet poster
 
Posts: 12
Default Switch Mail format

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  
Old July 6th 09, 03:17 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Switch Mail format

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  
Old July 6th 09, 03:36 PM posted to microsoft.public.outlook.program_vba
Mats Samson
external usenet poster
 
Posts: 12
Default Switch Mail format

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  
Old July 6th 09, 04:17 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Switch Mail format

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  
Old July 6th 09, 05:31 PM posted to microsoft.public.outlook.program_vba
Mats Samson
external usenet poster
 
Posts: 12
Default Switch Mail format

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  
Old July 6th 09, 07:56 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Switch Mail format

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  
Old July 18th 09, 10:13 AM posted to microsoft.public.outlook.program_vba
Mats Samson
external usenet poster
 
Posts: 12
Default Switch Mail format

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
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


All times are GMT +1. The time now is 07:59 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.