Group:  Microsoft Outlook » microsoft.public.outlook.program_vba
Thread: Sending mails from Excel 2003 - Outlook signature

Geek News

Sending mails from Excel 2003 - Outlook signature
"thomas" <nomail> 12/17/2008 11:02:05 PM
Hello,

Few months ago i asked ho to insert the outlook 2003 default signature to a
mail sent from excel vba

I was advised to use ".GetInspector" but i still cannot make it work.

I get an error message saying "read only property"


My code is :


Sub EnvoiMailMéthodeOLE(Adresse As String, Objet As String, Corps As String,
Optional Pièce As String, Optional Cc As String, Optional Bcc As String)

Dim MonAppliOutlook As New Outlook.Application
Dim MonMail As Outlook.MailItem
Dim MaPièce As Outlook.Attachments

Set MonMail = MonAppliOutlook.CreateItem(olMailItem)
MonAppliOutlook = MonMail.GetInspector

With MonMail
.Display '
.To = Adresse
If Not IsNull(Cc) Then .Cc = Cc
If Not IsNull(Bcc) Then .Bcc = Bcc
.Subject = Objet
.Body = Corps
If Not IsNull(Pièce) Then
Set MaPièce = .Attachments
MaPièce.Add Pièce, olByValue
End If
.Send
End With

End Sub

Thanks for you help

Re: Sending mails from Excel 2003 - Outlook signature
"Michael Bauer [MVP - Outlook]" <mb[ at ]mvps.org> 12/18/2008 10:58:21 AM

GetInspector returns an Inspector object, not an Application object. And
because it returns an object you'd need to use the Set statement. But
because you display the e-mail calling GetInspector shouldn't be necessary
at all.

After you've called Display, the Body property should contain the sig. That
is, calling .Body=Corps will overwerite the Body with the content of Corps.
If you want to preserve the content of Body and insert Corps at the top, you
need to do this:
..Body=Corps & .Body

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: <http://www.vboffice.net/product.html?pub=6&lang=en>



Am Thu, 18 Dec 2008 00:02:05 +0100 schrieb thomas:

[Quoted Text]
> Hello,
>
> Few months ago i asked ho to insert the outlook 2003 default signature to
a
> mail sent from excel vba
>
> I was advised to use ".GetInspector" but i still cannot make it work.
>
> I get an error message saying "read only property"
>
>
> My code is :
>
>
> Sub EnvoiMailMéthodeOLE(Adresse As String, Objet As String, Corps As
String,
> Optional Pièce As String, Optional Cc As String, Optional Bcc As String)
>
> Dim MonAppliOutlook As New Outlook.Application
> Dim MonMail As Outlook.MailItem
> Dim MaPièce As Outlook.Attachments
>
> Set MonMail = MonAppliOutlook.CreateItem(olMailItem)
> MonAppliOutlook = MonMail.GetInspector
>
> With MonMail
> .Display '
> .To = Adresse
> If Not IsNull(Cc) Then .Cc = Cc
> If Not IsNull(Bcc) Then .Bcc = Bcc
> .Subject = Objet
> .Body = Corps
> If Not IsNull(Pièce) Then
> Set MaPièce = .Attachments
> MaPièce.Add Pièce, olByValue
> End If
> .Send
> End With
>
> End Sub
>
> Thanks for you help
Re: Sending mails from Excel 2003 - Outlook signature
Todd SChram - SCWA 12/18/2008 7:52:02 PM
I had the same issue with losing my signature when sending code from Access.
I tried using your suggestion of:

..Body=txtNote & .Body

but did not successfully maintain my default signature in the new email. If
I don't define the .Body property the signature will come up fine.

Thanks.

Todd

"Michael Bauer [MVP - Outlook]" wrote:

[Quoted Text]
>
> GetInspector returns an Inspector object, not an Application object. And
> because it returns an object you'd need to use the Set statement. But
> because you display the e-mail calling GetInspector shouldn't be necessary
> at all.
>
> After you've called Display, the Body property should contain the sig. That
> is, calling .Body=Corps will overwerite the Body with the content of Corps.
> If you want to preserve the content of Body and insert Corps at the top, you
> need to do this:
> ..Body=Corps & .Body
>
> --
> Best regards
> Michael Bauer - MVP Outlook
>
> : Outlook Categories? Category Manager Is Your Tool
> : VBOffice Reporter for Data Analysis & Reporting
> : <http://www.vboffice.net/product.html?pub=6&lang=en>
>
>
>
> Am Thu, 18 Dec 2008 00:02:05 +0100 schrieb thomas:
>
> > Hello,
> >
> > Few months ago i asked ho to insert the outlook 2003 default signature to
> a
> > mail sent from excel vba
> >
> > I was advised to use ".GetInspector" but i still cannot make it work.
> >
> > I get an error message saying "read only property"
> >
> >
> > My code is :
> >
> >
> > Sub EnvoiMailMéthodeOLE(Adresse As String, Objet As String, Corps As
> String,
> > Optional Pièce As String, Optional Cc As String, Optional Bcc As String)
> >
> > Dim MonAppliOutlook As New Outlook.Application
> > Dim MonMail As Outlook.MailItem
> > Dim MaPièce As Outlook.Attachments
> >
> > Set MonMail = MonAppliOutlook.CreateItem(olMailItem)
> > MonAppliOutlook = MonMail.GetInspector
> >
> > With MonMail
> > .Display '
> > .To = Adresse
> > If Not IsNull(Cc) Then .Cc = Cc
> > If Not IsNull(Bcc) Then .Bcc = Bcc
> > .Subject = Objet
> > .Body = Corps
> > If Not IsNull(Pièce) Then
> > Set MaPièce = .Attachments
> > MaPièce.Add Pièce, olByValue
> > End If
> > .Send
> > End With
> >
> > End Sub
> >
> > Thanks for you help
>
Re : Sending mails from Excel 2003 - Outlook signature
"thomas" <nomail> 12/19/2008 11:30:21 PM
Thanks

I changed my code and I tried this :

#########################
Private Function EnvoiMail_HTML_New(Adresse As String, Objet As String,
Corps As String, Optional Pièce As String, Optional Cc As String, Optional
Bcc As String, Optional Envoyer_Mail As Boolean)

Dim MonAppliOutlook As Outlook.Application
Dim MonMail As Outlook.MailItem
Dim MaPièce As Outlook.Attachments

Set MonAppliOutlook = CreateObject("Outlook.Application")
Set MonMail = MonAppliOutlook.CreateItem(olMailItem)

On Error Resume Next

With MonMail

If Affichage = "OUI" Then .Display
.To = Adresse
If Not IsNull(Cc) Then .Cc = Cc
If Not IsNull(Bcc) Then .Bcc = Bcc
.BodyFormat = olFormatHTML
.HTMLBody = Corps & .HTMLBody


If Envoyer_Mail = True Then .Send

End With

Set MonAppliOutlook = Nothing
Set MonMail = Nothing

End Function
###########################


but with " .HTMLBody = Corps & .HTMLBody " i only get the signature
in the mail

and if i write " .HTMLBody = Corps " i only get the content of Corps

What did i do wrong?

Many thanks for your help

"Michael Bauer [MVP - Outlook]" <mb[ at ]mvps.org> a écrit dans le message de
groupe de discussion : 2oka6ili5r6l$.ibyd3lhmj01e.dlg[ at ]40tude.net...

GetInspector returns an Inspector object, not an Application object. And
because it returns an object you'd need to use the Set statement. But
because you display the e-mail calling GetInspector shouldn't be necessary
at all.

After you've called Display, the Body property should contain the sig. That
is, calling .Body=Corps will overwerite the Body with the content of Corps.
If you want to preserve the content of Body and insert Corps at the top, you
need to do this:
..Body=Corps & .Body

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: <http://www.vboffice.net/product.html?pub=6&lang=en>



Am Thu, 18 Dec 2008 00:02:05 +0100 schrieb thomas:

[Quoted Text]
> Hello,
>
> Few months ago i asked ho to insert the outlook 2003 default signature to
a
> mail sent from excel vba
>
> I was advised to use ".GetInspector" but i still cannot make it work.
>
> I get an error message saying "read only property"
>
>
> My code is :
>
>
> Sub EnvoiMailMéthodeOLE(Adresse As String, Objet As String, Corps As
String,
> Optional Pièce As String, Optional Cc As String, Optional Bcc As String)
>
> Dim MonAppliOutlook As New Outlook.Application
> Dim MonMail As Outlook.MailItem
> Dim MaPièce As Outlook.Attachments
>
> Set MonMail = MonAppliOutlook.CreateItem(olMailItem)
> MonAppliOutlook = MonMail.GetInspector
>
> With MonMail
> .Display '
> .To = Adresse
> If Not IsNull(Cc) Then .Cc = Cc
> If Not IsNull(Bcc) Then .Bcc = Bcc
> .Subject = Objet
> .Body = Corps
> If Not IsNull(Pièce) Then
> Set MaPièce = .Attachments
> MaPièce.Add Pièce, olByValue
> End If
> .Send
> End With
>
> End Sub
>
> Thanks for you help

Re : Sending mails from Excel 2003 - Outlook signature
"thomas" <nomail> 12/21/2008 7:04:59 PM
What do you think?

As said in previous post, whatever i write

..Body=Corps & .Body
or
.HTMLBody = Corps & .HTMLBody

it does not work


Thanks


"thomas" <nomail> a écrit dans le message de groupe de discussion :
#QBxKHjYJHA.1528[ at ]TK2MSFTNGP03.phx.gbl...
Thanks

I changed my code and I tried this :

#########################
Private Function EnvoiMail_HTML_New(Adresse As String, Objet As String,
Corps As String, Optional Pièce As String, Optional Cc As String, Optional
Bcc As String, Optional Envoyer_Mail As Boolean)

Dim MonAppliOutlook As Outlook.Application
Dim MonMail As Outlook.MailItem
Dim MaPièce As Outlook.Attachments

Set MonAppliOutlook = CreateObject("Outlook.Application")
Set MonMail = MonAppliOutlook.CreateItem(olMailItem)

On Error Resume Next

With MonMail

If Affichage = "OUI" Then .Display
.To = Adresse
If Not IsNull(Cc) Then .Cc = Cc
If Not IsNull(Bcc) Then .Bcc = Bcc
.BodyFormat = olFormatHTML
.HTMLBody = Corps & .HTMLBody


If Envoyer_Mail = True Then .Send

End With

Set MonAppliOutlook = Nothing
Set MonMail = Nothing

End Function
###########################


but with " .HTMLBody = Corps & .HTMLBody " i only get the signature
in the mail

and if i write " .HTMLBody = Corps " i only get the content of Corps

What did i do wrong?

Many thanks for your help

"Michael Bauer [MVP - Outlook]" <mb[ at ]mvps.org> a écrit dans le message de
groupe de discussion : 2oka6ili5r6l$.ibyd3lhmj01e.dlg[ at ]40tude.net...

GetInspector returns an Inspector object, not an Application object. And
because it returns an object you'd need to use the Set statement. But
because you display the e-mail calling GetInspector shouldn't be necessary
at all.

After you've called Display, the Body property should contain the sig. That
is, calling .Body=Corps will overwerite the Body with the content of Corps.
If you want to preserve the content of Body and insert Corps at the top, you
need to do this:
..Body=Corps & .Body

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: <http://www.vboffice.net/product.html?pub=6&lang=en>



Am Thu, 18 Dec 2008 00:02:05 +0100 schrieb thomas:

[Quoted Text]
> Hello,
>
> Few months ago i asked ho to insert the outlook 2003 default signature to
a
> mail sent from excel vba
>
> I was advised to use ".GetInspector" but i still cannot make it work.
>
> I get an error message saying "read only property"
>
>
> My code is :
>
>
> Sub EnvoiMailMéthodeOLE(Adresse As String, Objet As String, Corps As
String,
> Optional Pièce As String, Optional Cc As String, Optional Bcc As String)
>
> Dim MonAppliOutlook As New Outlook.Application
> Dim MonMail As Outlook.MailItem
> Dim MaPièce As Outlook.Attachments
>
> Set MonMail = MonAppliOutlook.CreateItem(olMailItem)
> MonAppliOutlook = MonMail.GetInspector
>
> With MonMail
> .Display '
> .To = Adresse
> If Not IsNull(Cc) Then .Cc = Cc
> If Not IsNull(Bcc) Then .Bcc = Bcc
> .Subject = Objet
> .Body = Corps
> If Not IsNull(Pièce) Then
> Set MaPièce = .Attachments
> MaPièce.Add Pièce, olByValue
> End If
> .Send
> End With
>
> End Sub
>
> Thanks for you help

Re : Sending mails from Excel 2003 - Outlook signature
"thomas" <nomail> 12/22/2008 9:59:55 AM
no hint on what i did wrong?

Thanks

"thomas" <nomail> a écrit dans le message de groupe de discussion :
#QBxKHjYJHA.1528[ at ]TK2MSFTNGP03.phx.gbl...
Thanks

I changed my code and I tried this :

#########################
Private Function EnvoiMail_HTML_New(Adresse As String, Objet As String,
Corps As String, Optional Pièce As String, Optional Cc As String, Optional
Bcc As String, Optional Envoyer_Mail As Boolean)

Dim MonAppliOutlook As Outlook.Application
Dim MonMail As Outlook.MailItem
Dim MaPièce As Outlook.Attachments

Set MonAppliOutlook = CreateObject("Outlook.Application")
Set MonMail = MonAppliOutlook.CreateItem(olMailItem)

On Error Resume Next

With MonMail

If Affichage = "OUI" Then .Display
.To = Adresse
If Not IsNull(Cc) Then .Cc = Cc
If Not IsNull(Bcc) Then .Bcc = Bcc
.BodyFormat = olFormatHTML
.HTMLBody = Corps & .HTMLBody


If Envoyer_Mail = True Then .Send

End With

Set MonAppliOutlook = Nothing
Set MonMail = Nothing

End Function
###########################


but with " .HTMLBody = Corps & .HTMLBody " i only get the signature
in the mail

and if i write " .HTMLBody = Corps " i only get the content of Corps

What did i do wrong?

Many thanks for your help

"Michael Bauer [MVP - Outlook]" <mb[ at ]mvps.org> a écrit dans le message de
groupe de discussion : 2oka6ili5r6l$.ibyd3lhmj01e.dlg[ at ]40tude.net...

GetInspector returns an Inspector object, not an Application object. And
because it returns an object you'd need to use the Set statement. But
because you display the e-mail calling GetInspector shouldn't be necessary
at all.

After you've called Display, the Body property should contain the sig. That
is, calling .Body=Corps will overwerite the Body with the content of Corps.
If you want to preserve the content of Body and insert Corps at the top, you
need to do this:
..Body=Corps & .Body

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: <http://www.vboffice.net/product.html?pub=6&lang=en>



Am Thu, 18 Dec 2008 00:02:05 +0100 schrieb thomas:

[Quoted Text]
> Hello,
>
> Few months ago i asked ho to insert the outlook 2003 default signature to
a
> mail sent from excel vba
>
> I was advised to use ".GetInspector" but i still cannot make it work.
>
> I get an error message saying "read only property"
>
>
> My code is :
>
>
> Sub EnvoiMailMéthodeOLE(Adresse As String, Objet As String, Corps As
String,
> Optional Pièce As String, Optional Cc As String, Optional Bcc As String)
>
> Dim MonAppliOutlook As New Outlook.Application
> Dim MonMail As Outlook.MailItem
> Dim MaPièce As Outlook.Attachments
>
> Set MonMail = MonAppliOutlook.CreateItem(olMailItem)
> MonAppliOutlook = MonMail.GetInspector
>
> With MonMail
> .Display '
> .To = Adresse
> If Not IsNull(Cc) Then .Cc = Cc
> If Not IsNull(Bcc) Then .Bcc = Bcc
> .Subject = Objet
> .Body = Corps
> If Not IsNull(Pièce) Then
> Set MaPièce = .Attachments
> MaPièce.Add Pièce, olByValue
> End If
> .Send
> End With
>
> End Sub
>
> Thanks for you help

Re : Sending mails from Excel 2003 - Outlook signature
"thomas" <nomail> 12/22/2008 8:43:51 PM
I found out

with the code .HTMLBody = Corps & .HTMLBody

i get an extra security message http://cjoint.com/data/mwwyjIyRHB.htm

if i answer OUI (YES) th signature is added

This secutity message is not very convenient.

Is there a way to avoid it with a permanent "YES" answer ?

Thanks


"thomas" <nomail> a écrit dans le message de groupe de discussion :
#QBxKHjYJHA.1528[ at ]TK2MSFTNGP03.phx.gbl...
Thanks

I changed my code and I tried this :

#########################
Private Function EnvoiMail_HTML_New(Adresse As String, Objet As String,
Corps As String, Optional Pièce As String, Optional Cc As String, Optional
Bcc As String, Optional Envoyer_Mail As Boolean)

Dim MonAppliOutlook As Outlook.Application
Dim MonMail As Outlook.MailItem
Dim MaPièce As Outlook.Attachments

Set MonAppliOutlook = CreateObject("Outlook.Application")
Set MonMail = MonAppliOutlook.CreateItem(olMailItem)

On Error Resume Next

With MonMail

If Affichage = "OUI" Then .Display
.To = Adresse
If Not IsNull(Cc) Then .Cc = Cc
If Not IsNull(Bcc) Then .Bcc = Bcc
.BodyFormat = olFormatHTML
.HTMLBody = Corps & .HTMLBody


If Envoyer_Mail = True Then .Send

End With

Set MonAppliOutlook = Nothing
Set MonMail = Nothing

End Function
###########################


but with " .HTMLBody = Corps & .HTMLBody " i only get the signature
in the mail

and if i write " .HTMLBody = Corps " i only get the content of Corps

What did i do wrong?

Many thanks for your help

"Michael Bauer [MVP - Outlook]" <mb[ at ]mvps.org> a écrit dans le message de
groupe de discussion : 2oka6ili5r6l$.ibyd3lhmj01e.dlg[ at ]40tude.net...

GetInspector returns an Inspector object, not an Application object. And
because it returns an object you'd need to use the Set statement. But
because you display the e-mail calling GetInspector shouldn't be necessary
at all.

After you've called Display, the Body property should contain the sig. That
is, calling .Body=Corps will overwerite the Body with the content of Corps.
If you want to preserve the content of Body and insert Corps at the top, you
need to do this:
..Body=Corps & .Body

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: <http://www.vboffice.net/product.html?pub=6&lang=en>



Am Thu, 18 Dec 2008 00:02:05 +0100 schrieb thomas:

[Quoted Text]
> Hello,
>
> Few months ago i asked ho to insert the outlook 2003 default signature to
a
> mail sent from excel vba
>
> I was advised to use ".GetInspector" but i still cannot make it work.
>
> I get an error message saying "read only property"
>
>
> My code is :
>
>
> Sub EnvoiMailMéthodeOLE(Adresse As String, Objet As String, Corps As
String,
> Optional Pièce As String, Optional Cc As String, Optional Bcc As String)
>
> Dim MonAppliOutlook As New Outlook.Application
> Dim MonMail As Outlook.MailItem
> Dim MaPièce As Outlook.Attachments
>
> Set MonMail = MonAppliOutlook.CreateItem(olMailItem)
> MonAppliOutlook = MonMail.GetInspector
>
> With MonMail
> .Display '
> .To = Adresse
> If Not IsNull(Cc) Then .Cc = Cc
> If Not IsNull(Bcc) Then .Bcc = Bcc
> .Subject = Objet
> .Body = Corps
> If Not IsNull(Pièce) Then
> Set MaPièce = .Attachments
> MaPièce.Add Pièce, olByValue
> End If
> .Send
> End With
>
> End Sub
>
> Thanks for you help

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net