|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Prevent attachments for being inserted into the bodyI am trying to attach a htm file to an email in outlook 2003 with vba, but the file is inserted into the body. How do I change that. Code below Hans Private Sub VedHaeftTilbud(HtmFile As String) Dim olApp As Outlook.Application Dim olMail As Outlook.MailItem Dim obj As Object Set olApp = New Outlook.Application Set obj = Me.GetCurrentItem() Set olMail = obj olMail.Attachments.Add HtmFile, olByValue Set olApp = Nothing End Sub Function GetCurrentItem() As Object Dim objApp As Outlook.Application Set objApp = CreateObject("Outlook.Application") On Error Resume Next Select Case TypeName(objApp.ActiveWindow) Case "Explorer" Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1) Case "Inspector" Set GetCurrentItem = objApp.ActiveInspector.CurrentItem Case Else ' anything else will result in an error, which is ' why we have the error handler above End Select Set objApp = Nothing End Function The placement of the attachments depends on the message format. RTF puts
them inline. HTML and plain text don't. -- Show quoteSue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "Hans Andersen" <h**@indu-flex.dk> wrote in message news:%23WlIgfDCFHA.1888@TK2MSFTNGP10.phx.gbl... > Hi all, > > I am trying to attach a htm file to an email in outlook 2003 with vba, but > the file is inserted into the body. How do I change that. Code below > > Hans > > > Private Sub VedHaeftTilbud(HtmFile As String) > > Dim olApp As Outlook.Application > Dim olMail As Outlook.MailItem > Dim obj As Object > > Set olApp = New Outlook.Application > > Set obj = Me.GetCurrentItem() > Set olMail = obj > > olMail.Attachments.Add HtmFile, olByValue > > Set olApp = Nothing > > End Sub > > Function GetCurrentItem() As Object > Dim objApp As Outlook.Application > > Set objApp = CreateObject("Outlook.Application") > On Error Resume Next > Select Case TypeName(objApp.ActiveWindow) > Case "Explorer" > Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1) > Case "Inspector" > Set GetCurrentItem = objApp.ActiveInspector.CurrentItem > Case Else > ' anything else will result in an error, which is > ' why we have the error handler above > End Select > > Set objApp = Nothing > End Function > That is not completely true.
if you replace olMail.Attachments.Add HtmFile, olByValue with Dim s As String s = olMail.HTMLBody olMail.Attachments.Add HtmFile, olByValue the result will be deferent. Unfortunately it makes Outlook go into panic security mode. It can also be done from the UI. I can not be the only one how wants separate the attachments from the body!? Hans Show quote "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message news:ehZAQaGCFHA.328@tk2msftngp13.phx.gbl... > The placement of the attachments depends on the message format. RTF puts > them inline. HTML and plain text don't. > > -- > Sue Mosher, Outlook MVP > Author of > Microsoft Outlook Programming - Jumpstart for > Administrators, Power Users, and Developers > http://www.outlookcode.com/jumpstart.aspx > > > "Hans Andersen" <h**@indu-flex.dk> wrote in message > news:%23WlIgfDCFHA.1888@TK2MSFTNGP10.phx.gbl... >> Hi all, >> >> I am trying to attach a htm file to an email in outlook 2003 with vba, >> but the file is inserted into the body. How do I change that. Code below >> >> Hans >> >> >> Private Sub VedHaeftTilbud(HtmFile As String) >> >> Dim olApp As Outlook.Application >> Dim olMail As Outlook.MailItem >> Dim obj As Object >> >> Set olApp = New Outlook.Application >> >> Set obj = Me.GetCurrentItem() >> Set olMail = obj >> >> olMail.Attachments.Add HtmFile, olByValue >> >> Set olApp = Nothing >> >> End Sub >> >> Function GetCurrentItem() As Object >> Dim objApp As Outlook.Application >> >> Set objApp = CreateObject("Outlook.Application") >> On Error Resume Next >> Select Case TypeName(objApp.ActiveWindow) >> Case "Explorer" >> Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1) >> Case "Inspector" >> Set GetCurrentItem = objApp.ActiveInspector.CurrentItem >> Case Else >> ' anything else will result in an error, which is >> ' why we have the error handler above >> End Select >> >> Set objApp = Nothing >> End Function >> > > You said nothing about how this is different or what message format you're
working with. -- Show quoteSue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "Hans Andersen" <h**@indu-flex.dk> wrote in message news:u0NaswGCFHA.3616@TK2MSFTNGP11.phx.gbl... > That is not completely true. > if you replace > olMail.Attachments.Add HtmFile, olByValue > with > Dim s As String > s = olMail.HTMLBody > olMail.Attachments.Add HtmFile, olByValue > the result will be deferent. > Unfortunately it makes Outlook go into panic security mode. > It can also be done from the UI. > > I can not be the only one how wants separate the attachments from the > body!? > > Hans > > > > "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message > news:ehZAQaGCFHA.328@tk2msftngp13.phx.gbl... >> The placement of the attachments depends on the message format. RTF puts >> them inline. HTML and plain text don't. >> >> >> "Hans Andersen" <h**@indu-flex.dk> wrote in message >> news:%23WlIgfDCFHA.1888@TK2MSFTNGP10.phx.gbl... >>> Hi all, >>> >>> I am trying to attach a htm file to an email in outlook 2003 with vba, >>> but the file is inserted into the body. How do I change that. Code >>> below >>> >>> Hans >>> >>> >>> Private Sub VedHaeftTilbud(HtmFile As String) >>> >>> Dim olApp As Outlook.Application >>> Dim olMail As Outlook.MailItem >>> Dim obj As Object >>> >>> Set olApp = New Outlook.Application >>> >>> Set obj = Me.GetCurrentItem() >>> Set olMail = obj >>> >>> olMail.Attachments.Add HtmFile, olByValue >>> >>> Set olApp = Nothing >>> >>> End Sub >>> >>> Function GetCurrentItem() As Object >>> Dim objApp As Outlook.Application >>> >>> Set objApp = CreateObject("Outlook.Application") >>> On Error Resume Next >>> Select Case TypeName(objApp.ActiveWindow) >>> Case "Explorer" >>> Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1) >>> Case "Inspector" >>> Set GetCurrentItem = objApp.ActiveInspector.CurrentItem >>> Case Else >>> ' anything else will result in an error, which is >>> ' why we have the error handler above >>> End Select >>> >>> Set objApp = Nothing >>> End Function >>> >> >> > > The message format is html.
Deferent in the location at the attachment. Hans Show quote "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message news:ew$bDAHCFHA.3120@TK2MSFTNGP12.phx.gbl... > You said nothing about how this is different or what message format you're > working with. > > -- > Sue Mosher, Outlook MVP > Author of > Microsoft Outlook Programming - Jumpstart for > Administrators, Power Users, and Developers > http://www.outlookcode.com/jumpstart.aspx > > > "Hans Andersen" <h**@indu-flex.dk> wrote in message > news:u0NaswGCFHA.3616@TK2MSFTNGP11.phx.gbl... >> That is not completely true. >> if you replace >> olMail.Attachments.Add HtmFile, olByValue >> with >> Dim s As String >> s = olMail.HTMLBody >> olMail.Attachments.Add HtmFile, olByValue >> the result will be deferent. >> Unfortunately it makes Outlook go into panic security mode. >> It can also be done from the UI. >> >> I can not be the only one how wants separate the attachments from the >> body!? >> >> Hans >> >> >> >> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message >> news:ehZAQaGCFHA.328@tk2msftngp13.phx.gbl... >>> The placement of the attachments depends on the message format. RTF puts >>> them inline. HTML and plain text don't. > >>> >>> >>> "Hans Andersen" <h**@indu-flex.dk> wrote in message >>> news:%23WlIgfDCFHA.1888@TK2MSFTNGP10.phx.gbl... >>>> Hi all, >>>> >>>> I am trying to attach a htm file to an email in outlook 2003 with vba, >>>> but the file is inserted into the body. How do I change that. Code >>>> below >>>> >>>> Hans >>>> >>>> >>>> Private Sub VedHaeftTilbud(HtmFile As String) >>>> >>>> Dim olApp As Outlook.Application >>>> Dim olMail As Outlook.MailItem >>>> Dim obj As Object >>>> >>>> Set olApp = New Outlook.Application >>>> >>>> Set obj = Me.GetCurrentItem() >>>> Set olMail = obj >>>> >>>> olMail.Attachments.Add HtmFile, olByValue >>>> >>>> Set olApp = Nothing >>>> >>>> End Sub >>>> >>>> Function GetCurrentItem() As Object >>>> Dim objApp As Outlook.Application >>>> >>>> Set objApp = CreateObject("Outlook.Application") >>>> On Error Resume Next >>>> Select Case TypeName(objApp.ActiveWindow) >>>> Case "Explorer" >>>> Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1) >>>> Case "Inspector" >>>> Set GetCurrentItem = objApp.ActiveInspector.CurrentItem >>>> Case Else >>>> ' anything else will result in an error, which is >>>> ' why we have the error handler above >>>> End Select >>>> >>>> Set objApp = Nothing >>>> End Function >>>> >>> >>> >> >> > > And what's different? An HTML-format message always shows attachments in a
separate little attachment pane, not in the message body. -- Show quoteSue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "Hans Andersen" <h**@indu-flex.dk> wrote in message news:%23%23f%23KIHCFHA.3096@TK2MSFTNGP14.phx.gbl... > The message format is html. > Deferent in the location at the attachment. > >>> That is not completely true. >>> if you replace >>> olMail.Attachments.Add HtmFile, olByValue >>> with >>> Dim s As String >>> s = olMail.HTMLBody >>> olMail.Attachments.Add HtmFile, olByValue >>> the result will be deferent. >>> Unfortunately it makes Outlook go into panic security mode. >>> It can also be done from the UI. >>> >>> I can not be the only one how wants separate the attachments from the >>> body!? >>> >>> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message >>> news:ehZAQaGCFHA.328@tk2msftngp13.phx.gbl... >>>> The placement of the attachments depends on the message format. RTF >>>> puts them inline. HTML and plain text don't. >> >>>> >>>> >>>> "Hans Andersen" <h**@indu-flex.dk> wrote in message >>>> news:%23WlIgfDCFHA.1888@TK2MSFTNGP10.phx.gbl... >>>>> Hi all, >>>>> >>>>> I am trying to attach a htm file to an email in outlook 2003 with vba, >>>>> but the file is inserted into the body. How do I change that. Code >>>>> below >>>>> >>>>> Hans >>>>> >>>>> >>>>> Private Sub VedHaeftTilbud(HtmFile As String) >>>>> >>>>> Dim olApp As Outlook.Application >>>>> Dim olMail As Outlook.MailItem >>>>> Dim obj As Object >>>>> >>>>> Set olApp = New Outlook.Application >>>>> >>>>> Set obj = Me.GetCurrentItem() >>>>> Set olMail = obj >>>>> >>>>> olMail.Attachments.Add HtmFile, olByValue >>>>> >>>>> Set olApp = Nothing >>>>> >>>>> End Sub >>>>> >>>>> Function GetCurrentItem() As Object >>>>> Dim objApp As Outlook.Application >>>>> >>>>> Set objApp = CreateObject("Outlook.Application") >>>>> On Error Resume Next >>>>> Select Case TypeName(objApp.ActiveWindow) >>>>> Case "Explorer" >>>>> Set GetCurrentItem = >>>>> objApp.ActiveExplorer.Selection.Item(1) >>>>> Case "Inspector" >>>>> Set GetCurrentItem = objApp.ActiveInspector.CurrentItem >>>>> Case Else >>>>> ' anything else will result in an error, which is >>>>> ' why we have the error handler above >>>>> End Select >>>>> >>>>> Set objApp = Nothing >>>>> End Function >>>>> >>>> >>>> >>> >>> >> >> > > Not here. It is at the end of the body. Just tried it on another computer.
Same results. Hans Show quote "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message news:Oq1pNQHCFHA.1404@TK2MSFTNGP11.phx.gbl... > And what's different? An HTML-format message always shows attachments in a > separate little attachment pane, not in the message body. > > -- > Sue Mosher, Outlook MVP > Author of > Microsoft Outlook Programming - Jumpstart for > Administrators, Power Users, and Developers > http://www.outlookcode.com/jumpstart.aspx > > > "Hans Andersen" <h**@indu-flex.dk> wrote in message > news:%23%23f%23KIHCFHA.3096@TK2MSFTNGP14.phx.gbl... >> The message format is html. >> Deferent in the location at the attachment. >> >>>> That is not completely true. >>>> if you replace >>>> olMail.Attachments.Add HtmFile, olByValue >>>> with >>>> Dim s As String >>>> s = olMail.HTMLBody >>>> olMail.Attachments.Add HtmFile, olByValue >>>> the result will be deferent. >>>> Unfortunately it makes Outlook go into panic security mode. >>>> It can also be done from the UI. >>>> >>>> I can not be the only one how wants separate the attachments from the >>>> body!? > >>>> >>>> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message >>>> news:ehZAQaGCFHA.328@tk2msftngp13.phx.gbl... >>>>> The placement of the attachments depends on the message format. RTF >>>>> puts them inline. HTML and plain text don't. >>> >>>>> >>>>> >>>>> "Hans Andersen" <h**@indu-flex.dk> wrote in message >>>>> news:%23WlIgfDCFHA.1888@TK2MSFTNGP10.phx.gbl... >>>>>> Hi all, >>>>>> >>>>>> I am trying to attach a htm file to an email in outlook 2003 with >>>>>> vba, but the file is inserted into the body. How do I change that. >>>>>> Code below >>>>>> >>>>>> Hans >>>>>> >>>>>> >>>>>> Private Sub VedHaeftTilbud(HtmFile As String) >>>>>> >>>>>> Dim olApp As Outlook.Application >>>>>> Dim olMail As Outlook.MailItem >>>>>> Dim obj As Object >>>>>> >>>>>> Set olApp = New Outlook.Application >>>>>> >>>>>> Set obj = Me.GetCurrentItem() >>>>>> Set olMail = obj >>>>>> >>>>>> olMail.Attachments.Add HtmFile, olByValue >>>>>> >>>>>> Set olApp = Nothing >>>>>> >>>>>> End Sub >>>>>> >>>>>> Function GetCurrentItem() As Object >>>>>> Dim objApp As Outlook.Application >>>>>> >>>>>> Set objApp = CreateObject("Outlook.Application") >>>>>> On Error Resume Next >>>>>> Select Case TypeName(objApp.ActiveWindow) >>>>>> Case "Explorer" >>>>>> Set GetCurrentItem = >>>>>> objApp.ActiveExplorer.Selection.Item(1) >>>>>> Case "Inspector" >>>>>> Set GetCurrentItem = objApp.ActiveInspector.CurrentItem >>>>>> Case Else >>>>>> ' anything else will result in an error, which is >>>>>> ' why we have the error handler above >>>>>> End Select >>>>>> >>>>>> Set objApp = Nothing >>>>>> End Function >>>>>> >>>>> >>>>> >>>> >>>> >>> >>> >> >> > > I bet that if you checked the message format, it would actually show as RTF.
-- Show quoteSue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "Hans Andersen" <h**@indu-flex.dk> wrote in message news:ODmsqaHCFHA.3616@TK2MSFTNGP11.phx.gbl... > Not here. It is at the end of the body. Just tried it on another computer. > Same results. > > Hans > > "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message > news:Oq1pNQHCFHA.1404@TK2MSFTNGP11.phx.gbl... >> And what's different? An HTML-format message always shows attachments in >> a separate little attachment pane, not in the message body. >> >> >> "Hans Andersen" <h**@indu-flex.dk> wrote in message >> news:%23%23f%23KIHCFHA.3096@TK2MSFTNGP14.phx.gbl... >>> The message format is html. >>> Deferent in the location at the attachment. >>> >>>>> That is not completely true. >>>>> if you replace >>>>> olMail.Attachments.Add HtmFile, olByValue >>>>> with >>>>> Dim s As String >>>>> s = olMail.HTMLBody >>>>> olMail.Attachments.Add HtmFile, olByValue >>>>> the result will be deferent. >>>>> Unfortunately it makes Outlook go into panic security mode. >>>>> It can also be done from the UI. >>>>> >>>>> I can not be the only one how wants separate the attachments from the >>>>> body!? >> >>>>> >>>>> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message >>>>> news:ehZAQaGCFHA.328@tk2msftngp13.phx.gbl... >>>>>> The placement of the attachments depends on the message format. RTF >>>>>> puts them inline. HTML and plain text don't. >>>> >>>>>> >>>>>> >>>>>> "Hans Andersen" <h**@indu-flex.dk> wrote in message >>>>>> news:%23WlIgfDCFHA.1888@TK2MSFTNGP10.phx.gbl... >>>>>>> Hi all, >>>>>>> >>>>>>> I am trying to attach a htm file to an email in outlook 2003 with >>>>>>> vba, but the file is inserted into the body. How do I change that. >>>>>>> Code below >>>>>>> >>>>>>> Hans >>>>>>> >>>>>>> >>>>>>> Private Sub VedHaeftTilbud(HtmFile As String) >>>>>>> >>>>>>> Dim olApp As Outlook.Application >>>>>>> Dim olMail As Outlook.MailItem >>>>>>> Dim obj As Object >>>>>>> >>>>>>> Set olApp = New Outlook.Application >>>>>>> >>>>>>> Set obj = Me.GetCurrentItem() >>>>>>> Set olMail = obj >>>>>>> >>>>>>> olMail.Attachments.Add HtmFile, olByValue >>>>>>> >>>>>>> Set olApp = Nothing >>>>>>> >>>>>>> End Sub >>>>>>> >>>>>>> Function GetCurrentItem() As Object >>>>>>> Dim objApp As Outlook.Application >>>>>>> >>>>>>> Set objApp = CreateObject("Outlook.Application") >>>>>>> On Error Resume Next >>>>>>> Select Case TypeName(objApp.ActiveWindow) >>>>>>> Case "Explorer" >>>>>>> Set GetCurrentItem = >>>>>>> objApp.ActiveExplorer.Selection.Item(1) >>>>>>> Case "Inspector" >>>>>>> Set GetCurrentItem = objApp.ActiveInspector.CurrentItem >>>>>>> Case Else >>>>>>> ' anything else will result in an error, which is >>>>>>> ' why we have the error handler above >>>>>>> End Select >>>>>>> >>>>>>> Set objApp = Nothing >>>>>>> End Function I only know one place to check that. Tools,Option,Mail format. It is html.
And here is another one. If the body is empty or it contains at html signature file it will gone into the body. If the body have some text in it, the attachment goes into the panel. Hans Show quote "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message news:OLkeDfHCFHA.2032@tk2msftngp13.phx.gbl... >I bet that if you checked the message format, it would actually show as >RTF. > > -- > Sue Mosher, Outlook MVP > Author of > Microsoft Outlook Programming - Jumpstart for > Administrators, Power Users, and Developers > http://www.outlookcode.com/jumpstart.aspx > > > "Hans Andersen" <h**@indu-flex.dk> wrote in message > news:ODmsqaHCFHA.3616@TK2MSFTNGP11.phx.gbl... >> Not here. It is at the end of the body. Just tried it on another >> computer. Same results. >> >> Hans >> >> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message >> news:Oq1pNQHCFHA.1404@TK2MSFTNGP11.phx.gbl... >>> And what's different? An HTML-format message always shows attachments in >>> a separate little attachment pane, not in the message body. >>> >>> >>> "Hans Andersen" <h**@indu-flex.dk> wrote in message >>> news:%23%23f%23KIHCFHA.3096@TK2MSFTNGP14.phx.gbl... >>>> The message format is html. >>>> Deferent in the location at the attachment. >>>> >>>>>> That is not completely true. >>>>>> if you replace >>>>>> olMail.Attachments.Add HtmFile, olByValue >>>>>> with >>>>>> Dim s As String >>>>>> s = olMail.HTMLBody >>>>>> olMail.Attachments.Add HtmFile, olByValue >>>>>> the result will be deferent. >>>>>> Unfortunately it makes Outlook go into panic security mode. >>>>>> It can also be done from the UI. >>>>>> >>>>>> I can not be the only one how wants separate the attachments from the >>>>>> body!? >>> >>>>>> >>>>>> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message >>>>>> news:ehZAQaGCFHA.328@tk2msftngp13.phx.gbl... >>>>>>> The placement of the attachments depends on the message format. RTF >>>>>>> puts them inline. HTML and plain text don't. >>>>> >>>>>>> >>>>>>> >>>>>>> "Hans Andersen" <h**@indu-flex.dk> wrote in message >>>>>>> news:%23WlIgfDCFHA.1888@TK2MSFTNGP10.phx.gbl... >>>>>>>> Hi all, >>>>>>>> >>>>>>>> I am trying to attach a htm file to an email in outlook 2003 with >>>>>>>> vba, but the file is inserted into the body. How do I change that. >>>>>>>> Code below >>>>>>>> >>>>>>>> Hans >>>>>>>> >>>>>>>> >>>>>>>> Private Sub VedHaeftTilbud(HtmFile As String) >>>>>>>> >>>>>>>> Dim olApp As Outlook.Application >>>>>>>> Dim olMail As Outlook.MailItem >>>>>>>> Dim obj As Object >>>>>>>> >>>>>>>> Set olApp = New Outlook.Application >>>>>>>> >>>>>>>> Set obj = Me.GetCurrentItem() >>>>>>>> Set olMail = obj >>>>>>>> >>>>>>>> olMail.Attachments.Add HtmFile, olByValue >>>>>>>> >>>>>>>> Set olApp = Nothing >>>>>>>> >>>>>>>> End Sub >>>>>>>> >>>>>>>> Function GetCurrentItem() As Object >>>>>>>> Dim objApp As Outlook.Application >>>>>>>> >>>>>>>> Set objApp = CreateObject("Outlook.Application") >>>>>>>> On Error Resume Next >>>>>>>> Select Case TypeName(objApp.ActiveWindow) >>>>>>>> Case "Explorer" >>>>>>>> Set GetCurrentItem = >>>>>>>> objApp.ActiveExplorer.Selection.Item(1) >>>>>>>> Case "Inspector" >>>>>>>> Set GetCurrentItem = objApp.ActiveInspector.CurrentItem >>>>>>>> Case Else >>>>>>>> ' anything else will result in an error, which is >>>>>>>> ' why we have the error handler above >>>>>>>> End Select >>>>>>>> >>>>>>>> Set objApp = Nothing >>>>>>>> End Function > > Tools | Options | Mail Format only tells you the default mail format. It
tells you nothing at all about any message that has already been created. I was suggesting that you check the format of the actual message with Outlook Spy or your own VBA code. -- Show quoteSue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "Hans Andersen" <h**@indu-flex.dk> wrote in message news:%234mNmmHCFHA.1084@tk2msftngp13.phx.gbl... >I only know one place to check that. Tools,Option,Mail format. It is html. > > And here is another one. If the body is empty or it contains at html > signature file it will gone into the body. If the body have some text in > it, the attachment goes into the panel. > > > Hans > > "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message > news:OLkeDfHCFHA.2032@tk2msftngp13.phx.gbl... >>I bet that if you checked the message format, it would actually show as >>RTF. >> >> "Hans Andersen" <h**@indu-flex.dk> wrote in message >> news:ODmsqaHCFHA.3616@TK2MSFTNGP11.phx.gbl... >>> Not here. It is at the end of the body. Just tried it on another >>> computer. Same results. >>> >>> Hans >>> >>> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message >>> news:Oq1pNQHCFHA.1404@TK2MSFTNGP11.phx.gbl... >>>> And what's different? An HTML-format message always shows attachments >>>> in a separate little attachment pane, not in the message body. >>>> >>>> >>>> "Hans Andersen" <h**@indu-flex.dk> wrote in message >>>> news:%23%23f%23KIHCFHA.3096@TK2MSFTNGP14.phx.gbl... >>>>> The message format is html. >>>>> Deferent in the location at the attachment. >>>>> >>>>>>> That is not completely true. >>>>>>> if you replace >>>>>>> olMail.Attachments.Add HtmFile, olByValue >>>>>>> with >>>>>>> Dim s As String >>>>>>> s = olMail.HTMLBody >>>>>>> olMail.Attachments.Add HtmFile, olByValue >>>>>>> the result will be deferent. >>>>>>> Unfortunately it makes Outlook go into panic security mode. >>>>>>> It can also be done from the UI. >>>>>>> >>>>>>> I can not be the only one how wants separate the attachments from >>>>>>> the body!? >>>> >>>>>>> >>>>>>> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message >>>>>>> news:ehZAQaGCFHA.328@tk2msftngp13.phx.gbl... >>>>>>>> The placement of the attachments depends on the message format. RTF >>>>>>>> puts them inline. HTML and plain text don't. >>>>>> >>>>>>>> >>>>>>>> >>>>>>>> "Hans Andersen" <h**@indu-flex.dk> wrote in message >>>>>>>> news:%23WlIgfDCFHA.1888@TK2MSFTNGP10.phx.gbl... >>>>>>>>> Hi all, >>>>>>>>> >>>>>>>>> I am trying to attach a htm file to an email in outlook 2003 with >>>>>>>>> vba, but the file is inserted into the body. How do I change that. >>>>>>>>> Code below >>>>>>>>> >>>>>>>>> Hans >>>>>>>>> >>>>>>>>> >>>>>>>>> Private Sub VedHaeftTilbud(HtmFile As String) >>>>>>>>> >>>>>>>>> Dim olApp As Outlook.Application >>>>>>>>> Dim olMail As Outlook.MailItem >>>>>>>>> Dim obj As Object >>>>>>>>> >>>>>>>>> Set olApp = New Outlook.Application >>>>>>>>> >>>>>>>>> Set obj = Me.GetCurrentItem() >>>>>>>>> Set olMail = obj >>>>>>>>> >>>>>>>>> olMail.Attachments.Add HtmFile, olByValue >>>>>>>>> >>>>>>>>> Set olApp = Nothing >>>>>>>>> >>>>>>>>> End Sub >>>>>>>>> >>>>>>>>> Function GetCurrentItem() As Object >>>>>>>>> Dim objApp As Outlook.Application >>>>>>>>> >>>>>>>>> Set objApp = CreateObject("Outlook.Application") >>>>>>>>> On Error Resume Next >>>>>>>>> Select Case TypeName(objApp.ActiveWindow) >>>>>>>>> Case "Explorer" >>>>>>>>> Set GetCurrentItem = >>>>>>>>> objApp.ActiveExplorer.Selection.Item(1) >>>>>>>>> Case "Inspector" >>>>>>>>> Set GetCurrentItem = objApp.ActiveInspector.CurrentItem >>>>>>>>> Case Else >>>>>>>>> ' anything else will result in an error, which is >>>>>>>>> ' why we have the error handler above >>>>>>>>> End Select >>>>>>>>> >>>>>>>>> Set objApp = Nothing >>>>>>>>> End Function >> >> > > It's a new mail.
Hans Show quote "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message news:OOr%23sUICFHA.1188@tk2msftngp13.phx.gbl... > Tools | Options | Mail Format only tells you the default mail format. It > tells you nothing at all about any message that has already been created. > > I was suggesting that you check the format of the actual message with > Outlook Spy or your own VBA code. > > -- > Sue Mosher, Outlook MVP > Author of > Microsoft Outlook Programming - Jumpstart for > Administrators, Power Users, and Developers > http://www.outlookcode.com/jumpstart.aspx > > > "Hans Andersen" <h**@indu-flex.dk> wrote in message > news:%234mNmmHCFHA.1084@tk2msftngp13.phx.gbl... >>I only know one place to check that. Tools,Option,Mail format. It is html. >> >> And here is another one. If the body is empty or it contains at html >> signature file it will gone into the body. If the body have some text in >> it, the attachment goes into the panel. >> >> >> Hans >> >> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message >> news:OLkeDfHCFHA.2032@tk2msftngp13.phx.gbl... >>>I bet that if you checked the message format, it would actually show as >>>RTF. > >>> >>> "Hans Andersen" <h**@indu-flex.dk> wrote in message >>> news:ODmsqaHCFHA.3616@TK2MSFTNGP11.phx.gbl... >>>> Not here. It is at the end of the body. Just tried it on another >>>> computer. Same results. >>>> >>>> Hans >>>> >>>> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message >>>> news:Oq1pNQHCFHA.1404@TK2MSFTNGP11.phx.gbl... >>>>> And what's different? An HTML-format message always shows attachments >>>>> in a separate little attachment pane, not in the message body. >>>>> >>>>> >>>>> "Hans Andersen" <h**@indu-flex.dk> wrote in message >>>>> news:%23%23f%23KIHCFHA.3096@TK2MSFTNGP14.phx.gbl... >>>>>> The message format is html. >>>>>> Deferent in the location at the attachment. >>>>>> >>>>>>>> That is not completely true. >>>>>>>> if you replace >>>>>>>> olMail.Attachments.Add HtmFile, olByValue >>>>>>>> with >>>>>>>> Dim s As String >>>>>>>> s = olMail.HTMLBody >>>>>>>> olMail.Attachments.Add HtmFile, olByValue >>>>>>>> the result will be deferent. >>>>>>>> Unfortunately it makes Outlook go into panic security mode. >>>>>>>> It can also be done from the UI. >>>>>>>> >>>>>>>> I can not be the only one how wants separate the attachments from >>>>>>>> the body!? >>>>> >>>>>>>> >>>>>>>> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in >>>>>>>> message news:ehZAQaGCFHA.328@tk2msftngp13.phx.gbl... >>>>>>>>> The placement of the attachments depends on the message format. >>>>>>>>> RTF puts them inline. HTML and plain text don't. >>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> "Hans Andersen" <h**@indu-flex.dk> wrote in message >>>>>>>>> news:%23WlIgfDCFHA.1888@TK2MSFTNGP10.phx.gbl... >>>>>>>>>> Hi all, >>>>>>>>>> >>>>>>>>>> I am trying to attach a htm file to an email in outlook 2003 with >>>>>>>>>> vba, but the file is inserted into the body. How do I change >>>>>>>>>> that. Code below >>>>>>>>>> >>>>>>>>>> Hans >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> Private Sub VedHaeftTilbud(HtmFile As String) >>>>>>>>>> >>>>>>>>>> Dim olApp As Outlook.Application >>>>>>>>>> Dim olMail As Outlook.MailItem >>>>>>>>>> Dim obj As Object >>>>>>>>>> >>>>>>>>>> Set olApp = New Outlook.Application >>>>>>>>>> >>>>>>>>>> Set obj = Me.GetCurrentItem() >>>>>>>>>> Set olMail = obj >>>>>>>>>> >>>>>>>>>> olMail.Attachments.Add HtmFile, olByValue >>>>>>>>>> >>>>>>>>>> Set olApp = Nothing >>>>>>>>>> >>>>>>>>>> End Sub >>>>>>>>>> >>>>>>>>>> Function GetCurrentItem() As Object >>>>>>>>>> Dim objApp As Outlook.Application >>>>>>>>>> >>>>>>>>>> Set objApp = CreateObject("Outlook.Application") >>>>>>>>>> On Error Resume Next >>>>>>>>>> Select Case TypeName(objApp.ActiveWindow) >>>>>>>>>> Case "Explorer" >>>>>>>>>> Set GetCurrentItem = >>>>>>>>>> objApp.ActiveExplorer.Selection.Item(1) >>>>>>>>>> Case "Inspector" >>>>>>>>>> Set GetCurrentItem = >>>>>>>>>> objApp.ActiveInspector.CurrentItem >>>>>>>>>> Case Else >>>>>>>>>> ' anything else will result in an error, which is >>>>>>>>>> ' why we have the error handler above >>>>>>>>>> End Select >>>>>>>>>> >>>>>>>>>> Set objApp = Nothing >>>>>>>>>> End Function >>> >>> >> >> > > So, did you try what I suggested?
-- Show quoteSue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "Hans Andersen" <h**@indu-flex.dk> wrote in message news:O8UsPZICFHA.3708@TK2MSFTNGP14.phx.gbl... > It's a new mail. > > Hans > "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message > news:OOr%23sUICFHA.1188@tk2msftngp13.phx.gbl... >> Tools | Options | Mail Format only tells you the default mail format. It >> tells you nothing at all about any message that has already been created. >> >> I was suggesting that you check the format of the actual message with >> Outlook Spy or your own VBA code. >> >> >> "Hans Andersen" <h**@indu-flex.dk> wrote in message >> news:%234mNmmHCFHA.1084@tk2msftngp13.phx.gbl... >>>I only know one place to check that. Tools,Option,Mail format. It is >>>html. >>> >>> And here is another one. If the body is empty or it contains at html >>> signature file it will gone into the body. If the body have some text in >>> it, the attachment goes into the panel. >>> >>> >>> Hans >>> >>> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message >>> news:OLkeDfHCFHA.2032@tk2msftngp13.phx.gbl... >>>>I bet that if you checked the message format, it would actually show as >>>>RTF. >> >>>> >>>> "Hans Andersen" <h**@indu-flex.dk> wrote in message >>>> news:ODmsqaHCFHA.3616@TK2MSFTNGP11.phx.gbl... >>>>> Not here. It is at the end of the body. Just tried it on another >>>>> computer. Same results. >>>>> >>>>> Hans >>>>> >>>>> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message >>>>> news:Oq1pNQHCFHA.1404@TK2MSFTNGP11.phx.gbl... >>>>>> And what's different? An HTML-format message always shows attachments >>>>>> in a separate little attachment pane, not in the message body. >>>>>> >>>>>> >>>>>> "Hans Andersen" <h**@indu-flex.dk> wrote in message >>>>>> news:%23%23f%23KIHCFHA.3096@TK2MSFTNGP14.phx.gbl... >>>>>>> The message format is html. >>>>>>> Deferent in the location at the attachment. >>>>>>> >>>>>>>>> That is not completely true. >>>>>>>>> if you replace >>>>>>>>> olMail.Attachments.Add HtmFile, olByValue >>>>>>>>> with >>>>>>>>> Dim s As String >>>>>>>>> s = olMail.HTMLBody >>>>>>>>> olMail.Attachments.Add HtmFile, olByValue >>>>>>>>> the result will be deferent. >>>>>>>>> Unfortunately it makes Outlook go into panic security mode. >>>>>>>>> It can also be done from the UI. >>>>>>>>> >>>>>>>>> I can not be the only one how wants separate the attachments from >>>>>>>>> the body!? >>>>>> >>>>>>>>> >>>>>>>>> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in >>>>>>>>> message news:ehZAQaGCFHA.328@tk2msftngp13.phx.gbl... >>>>>>>>>> The placement of the attachments depends on the message format. >>>>>>>>>> RTF puts them inline. HTML and plain text don't. >>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> "Hans Andersen" <h**@indu-flex.dk> wrote in message >>>>>>>>>> news:%23WlIgfDCFHA.1888@TK2MSFTNGP10.phx.gbl... >>>>>>>>>>> Hi all, >>>>>>>>>>> >>>>>>>>>>> I am trying to attach a htm file to an email in outlook 2003 >>>>>>>>>>> with vba, but the file is inserted into the body. How do I >>>>>>>>>>> change that. Code below >>>>>>>>>>> >>>>>>>>>>> Hans >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> Private Sub VedHaeftTilbud(HtmFile As String) >>>>>>>>>>> >>>>>>>>>>> Dim olApp As Outlook.Application >>>>>>>>>>> Dim olMail As Outlook.MailItem >>>>>>>>>>> Dim obj As Object >>>>>>>>>>> >>>>>>>>>>> Set olApp = New Outlook.Application >>>>>>>>>>> >>>>>>>>>>> Set obj = Me.GetCurrentItem() >>>>>>>>>>> Set olMail = obj >>>>>>>>>>> >>>>>>>>>>> olMail.Attachments.Add HtmFile, olByValue >>>>>>>>>>> >>>>>>>>>>> Set olApp = Nothing >>>>>>>>>>> >>>>>>>>>>> End Sub >>>>>>>>>>> >>>>>>>>>>> Function GetCurrentItem() As Object >>>>>>>>>>> Dim objApp As Outlook.Application >>>>>>>>>>> >>>>>>>>>>> Set objApp = CreateObject("Outlook.Application") >>>>>>>>>>> On Error Resume Next >>>>>>>>>>> Select Case TypeName(objApp.ActiveWindow) >>>>>>>>>>> Case "Explorer" >>>>>>>>>>> Set GetCurrentItem = >>>>>>>>>>> objApp.ActiveExplorer.Selection.Item(1) >>>>>>>>>>> Case "Inspector" >>>>>>>>>>> Set GetCurrentItem = >>>>>>>>>>> objApp.ActiveInspector.CurrentItem >>>>>>>>>>> Case Else >>>>>>>>>>> ' anything else will result in an error, which is >>>>>>>>>>> ' why we have the error handler above >>>>>>>>>>> End Select >>>>>>>>>>> >>>>>>>>>>> Set objApp = Nothing >>>>>>>>>>> End Function >>>> >>>> >>> >>> >> >> > > The code below will attach a html fil (<html>i'm html</html>) to a new mail
created with ctl+n. If the body is empty, the fil goes into the body. If the body is not empty, say it contains a single "s", then the fil goes into the panel. If the body contains a signatur fil, the file goes into the body. If the code run twice, the fil goes into the body the first time and into the panel the second time. Hans Dim olApp As Outlook.Application Dim olMail As Outlook.MailItem Dim obj As Object Set olApp = CreateObject("Outlook.Application") Set olMail = olApp.ActiveInspector.CurrentItem If olMail.BodyFormat = olFormatHTML Then olMail.Attachments.Add "c:\temp\temp.htm", olByValue End If Show quote "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message news:uaXgYHKCFHA.612@TK2MSFTNGP09.phx.gbl... > So, did you try what I suggested? > > -- > Sue Mosher, Outlook MVP > Author of > Microsoft Outlook Programming - Jumpstart for > Administrators, Power Users, and Developers > http://www.outlookcode.com/jumpstart.aspx > > > "Hans Andersen" <h**@indu-flex.dk> wrote in message > news:O8UsPZICFHA.3708@TK2MSFTNGP14.phx.gbl... >> It's a new mail. >> >> Hans >> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message >> news:OOr%23sUICFHA.1188@tk2msftngp13.phx.gbl... >>> Tools | Options | Mail Format only tells you the default mail format. It >>> tells you nothing at all about any message that has already been >>> created. >>> >>> I was suggesting that you check the format of the actual message with >>> Outlook Spy or your own VBA code. >>> >>> >>> "Hans Andersen" <h**@indu-flex.dk> wrote in message >>> news:%234mNmmHCFHA.1084@tk2msftngp13.phx.gbl... >>>>I only know one place to check that. Tools,Option,Mail format. It is >>>>html. >>>> >>>> And here is another one. If the body is empty or it contains at html >>>> signature file it will gone into the body. If the body have some text >>>> in it, the attachment goes into the panel. >>>> >>>> >>>> Hans >>>> >>>> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message >>>> news:OLkeDfHCFHA.2032@tk2msftngp13.phx.gbl... >>>>>I bet that if you checked the message format, it would actually show as >>>>>RTF. >>> >>>>> >>>>> "Hans Andersen" <h**@indu-flex.dk> wrote in message >>>>> news:ODmsqaHCFHA.3616@TK2MSFTNGP11.phx.gbl... >>>>>> Not here. It is at the end of the body. Just tried it on another >>>>>> computer. Same results. >>>>>> >>>>>> Hans >>>>>> >>>>>> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in message >>>>>> news:Oq1pNQHCFHA.1404@TK2MSFTNGP11.phx.gbl... >>>>>>> And what's different? An HTML-format message always shows >>>>>>> attachments in a separate little attachment pane, not in the message >>>>>>> body. >>>>>>> >>>>>>> >>>>>>> "Hans Andersen" <h**@indu-flex.dk> wrote in message >>>>>>> news:%23%23f%23KIHCFHA.3096@TK2MSFTNGP14.phx.gbl... >>>>>>>> The message format is html. >>>>>>>> Deferent in the location at the attachment. >>>>>>>> >>>>>>>>>> That is not completely true. >>>>>>>>>> if you replace >>>>>>>>>> olMail.Attachments.Add HtmFile, olByValue >>>>>>>>>> with >>>>>>>>>> Dim s As String >>>>>>>>>> s = olMail.HTMLBody >>>>>>>>>> olMail.Attachments.Add HtmFile, olByValue >>>>>>>>>> the result will be deferent. >>>>>>>>>> Unfortunately it makes Outlook go into panic security mode. >>>>>>>>>> It can also be done from the UI. >>>>>>>>>> >>>>>>>>>> I can not be the only one how wants separate the attachments from >>>>>>>>>> the body!? >>>>>>> >>>>>>>>>> >>>>>>>>>> "Sue Mosher [MVP-Outlook]" <sue***@outlookcode.com> wrote in >>>>>>>>>> message news:ehZAQaGCFHA.328@tk2msftngp13.phx.gbl... >>>>>>>>>>> The placement of the attachments depends on the message format. >>>>>>>>>>> RTF puts them inline. HTML and plain text don't. >>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> "Hans Andersen" <h**@indu-flex.dk> wrote in message >>>>>>>>>>> news:%23WlIgfDCFHA.1888@TK2MSFTNGP10.phx.gbl... >>>>>>>>>>>> Hi all, >>>>>>>>>>>> >>>>>>>>>>>> I am trying to attach a htm file to an email in outlook 2003 >>>>>>>>>>>> with vba, but the file is inserted into the body. How do I >>>>>>>>>>>> change that. Code below >>>>>>>>>>>> >>>>>>>>>>>> Hans >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> Private Sub VedHaeftTilbud(HtmFile As String) >>>>>>>>>>>> >>>>>>>>>>>> Dim olApp As Outlook.Application >>>>>>>>>>>> Dim olMail As Outlook.MailItem >>>>>>>>>>>> Dim obj As Object >>>>>>>>>>>> >>>>>>>>>>>> Set olApp = New Outlook.Application >>>>>>>>>>>> >>>>>>>>>>>> Set obj = Me.GetCurrentItem() >>>>>>>>>>>> Set olMail = obj >>>>>>>>>>>> >>>>>>>>>>>> olMail.Attachments.Add HtmFile, olByValue >>>>>>>>>>>> >>>>>>>>>>>> Set olApp = Nothing >>>>>>>>>>>> >>>>>>>>>>>> End Sub >>>>>>>>>>>> >>>>>>>>>>>> Function GetCurrentItem() As Object >>>>>>>>>>>> Dim objApp As Outlook.Application >>>>>>>>>>>> >>>>>>>>>>>> Set objApp = CreateObject("Outlook.Application") >>>>>>>>>>>> On Error Resume Next >>>>>>>>>>>> Select Case TypeName(objApp.ActiveWindow) >>>>>>>>>>>> Case "Explorer" >>>>>>>>>>>> Set GetCurrentItem = >>>>>>>>>>>> objApp.ActiveExplorer.Selection.Item(1) >>>>>>>>>>>> Case "Inspector" >>>>>>>>>>>> Set GetCurrentItem = >>>>>>>>>>>> objApp.ActiveInspector.CurrentItem >>>>>>>>>>>> Case Else >>>>>>>>>>>> ' anything else will result in an error, which is >>>>>>>>>>>> ' why we have the error handler above >>>>>>>>>>>> End Select >>>>>>>>>>>> >>>>>>>>>>>> Set objApp = Nothing >>>>>>>>>>>> End Function >>>>> >>>>> >>>> >>>> >>> >>> >> >> > > Thanks for providing a sufficient test scenario. Now I can see that what you
meant was not that the file is appearing in the body, as it would in an RTF format message, but that the ***HTML content*** of the file is being incorporated into the HTMLBody of the message. It reproduces here exactly as you outline below. As far as I know, this is a previously unidentified bug in Outlook 2003. (I tested in SP1.) We'll ask Microsoft about it and report back if they can shed any light. I have found two workarounds: 1) Use WordMail as the editor. 2) Set HTMLBody before adding the attachment. To avoid a security prompt, you will need to use the intrinsic Application object in Outlook VBA: Set olMail = Application.ActiveInspector.CurrentItem If olMail.BodyFormat = olFormatHTML Then strBody = olMail.HTMLBody olMail.HTMLBody = strBody olMail.Attachments.Add "c:\temp\temp.htm", olByValue End If -- Show quoteSue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "Hans Andersen" <h**@indu-flex.dk> wrote in message news:ueDtoaPCFHA.1396@TK2MSFTNGP14.phx.gbl... > The code below will attach a html fil (<html>i'm html</html>) to a new > mail created with ctl+n. > If the body is empty, the fil goes into the body. > If the body is not empty, say it contains a single "s", then the fil goes > into the panel. > If the body contains a signatur fil, the file goes into the body. > If the code run twice, the fil goes into the body the first time and into > the panel the second time. > > Hans > > Dim olApp As Outlook.Application > Dim olMail As Outlook.MailItem > Dim obj As Object > > Set olApp = CreateObject("Outlook.Application") > Set olMail = olApp.ActiveInspector.CurrentItem > > If olMail.BodyFormat = olFormatHTML Then > olMail.Attachments.Add "c:\temp\temp.htm", olByValue > End If > |
|||||||||||||||||||||||