Switch Mail format

Status
Not open for further replies.
M

Mats Samson

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
 
K

Ken Slovak - [MVP - Outlook]

When the item opens you can set its BodyFormat property. You would set that

to OlBodyFormat.olFormatPlain.

"Mats Samson" <MatsSamson> wrote in message

news:151B97DF-6D87-41FD-AD66-DACA036C3CBD@microsoft.com...
> 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
 
M

Mats Samson

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
wrote:


> When the item opens you can set its BodyFormat property. You would set that
> to OlBodyFormat.olFormatPlain.

> >

>

> "Mats Samson" <MatsSamson> wrote in message
> news:151B97DF-6D87-41FD-AD66-DACA036C3CBD@microsoft.com...
> > 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


>
 
K

Ken Slovak - [MVP - Outlook]

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

"Mats Samson" <MatsSamson> wrote in message

news:75E68B38-E8F8-46A6-A824-4B7424116942@microsoft.com...
> 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
 
M

Mats Samson

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

> >

>

> "Mats Samson" <MatsSamson> wrote in message
> news:75E68B38-E8F8-46A6-A824-4B7424116942@microsoft.com...
> > 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


>
 
K

Ken Slovak - [MVP - Outlook]

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.

"Mats Samson" <MatsSamson> wrote in message

news:DAF0CD66-15DC-49BD-9A91-85F0EA804773@microsoft.com...
> 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
 
M

Mats Samson

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
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.

> >

>

> "Mats Samson" <MatsSamson> wrote in message
> news:DAF0CD66-15DC-49BD-9A91-85F0EA804773@microsoft.com...
> > 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


>
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
T How to determine when I switch from mail to calendar etc. Using Outlook 9
Commodore Automatic switch between working offline/online Using Outlook 4
e_a_g_l_e_p_i A few question before I decide to switch to Pop from imap Using Outlook 9
O How to recover rules after switch from POP3 to IMAP Using Outlook 2
E Accessing shared outlook folder doesn't work since switch to new outlook/excel Outlook VBA and Custom Forms 11
D Outlook 2016: /altvba startup switch does not work Using Outlook 2
J VBA to switch Outlook online/offline Outlook VBA and Custom Forms 4
George Simpson "Switch to HTML" in Outlook 2016 notes field Using Outlook 1
B Switch template with account Outlook VBA and Custom Forms 3
P How to switch back from Outlook 2010 to Outlook 2007? Using Outlook 3
B Outlook 2010: using /altvba switch Using Outlook 1
E Should I switch to IMAP? Using Outlook 0
wisedave Switch from POP3 over to IMAP Using Outlook 3
K Can Outlook be launched with the /cleanreminders switch multiple times? Using Outlook 2
W How to switch my list view back to normal view Using Outlook 1
E Should I switch to redemption Outlook VBA and Custom Forms 11
E Should I switch to redemption Outlook VBA and Custom Forms 11
U Using /a switch to send multiple files? Outlook VBA and Custom Forms 1
Aussie Outlook 365 Rule runs manually but returns the error code "an unexpected error has occurred" when incoming mail arrives Using Outlook 0
D ISOmacro to extract active mail senders name and email, CC, Subject line, and filename of attachments and import them into premade excel spread sheet Outlook VBA and Custom Forms 2
witzker Outlook 2019 Macro to answer a mail with attachments Outlook VBA and Custom Forms 2
D Outlook 2003 Mail Fails Using Outlook 1
Cathy Rhone Mail merge error message Using Outlook 2
R Sent emails show iCloud mail account not the alias Using Outlook 2
D Advanced e-Mail search on from/to contact group only searches for first 20 contacts in group Using Outlook 0
P Print attachments automatically and move the mail to an existing folder called "Ted" Outlook VBA and Custom Forms 4
P Importing other e-mail accounts into Outlook Using Outlook 1
lcarpay Stay in the mail folder pane after ctrl-1 Using Outlook 1
O Exchange Sync period only (e.g. last years mail) Using Outlook 0
F Excel VBA to move mails for outlook 365 on secondary mail account Outlook VBA and Custom Forms 1
M Convertor for Outlook Express Mail Store (.dbx) to Outlook Mail Store (.pst) Using Outlook 0
T vba extract data from msg file as attachment file of mail message Outlook VBA and Custom Forms 1
J E-mail held in Outbox while Minimized Using Outlook 3
G Forward email body to other mail list directly from Exchange server Exchange Server Administration 1
T Outlook creates a copie of every mail I send Using Outlook.com accounts in Outlook 4
N Please advise code received new mail Using Outlook 0
M Outlook 2010 How could I globally redesign an outlook template form/region/inspector template used to display mail lists or an individual mails? Outlook VBA and Custom Forms 0
A How to stop user form from disapearing once mail window is closed? Outlook VBA and Custom Forms 0
M Outlook, send to > mail recipient - results in plain text email Using Outlook 1
R How to Sync *all* Google Workspace Mail Folders with Outlook 2019 (MS365) Using Outlook 3
S Outlook VBA How to adapt this code for using in a different Mail Inbox Outlook VBA and Custom Forms 0
E Having some trouble with a run-a-script rule (moving mail based on file type) Outlook VBA and Custom Forms 5
S Outlook email to configure setup for each mail Outlook VBA and Custom Forms 1
L Correct E-Mail Pulling Wrong Mail Using Outlook 5
S Outlook mail adressing stops after first match in GAL Using Outlook 0
P Outlook 2013 All imported Mail Rules in error when imported into new profile Using Outlook 5
S Outlook Macro to send auto acknowledge mail only to new mails received to a specific shared inbox Outlook VBA and Custom Forms 0
S Outlook Macro to move reply mail based on the key word in the subjectline Outlook VBA and Custom Forms 0
MrMayor SENT mail not reloading to top?? Using Outlook 4
Terry Sullivan Sender Field Displays My E-Mail Address, Not My Name Using Outlook 1

Similar threads

Top