msoutlook.org Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Insert standard text into a new message

 
Post new topic   Reply to topic    msoutlook.org Forum Index -> Outlook Program VBA
Author Message
Gabe



Joined: 12 Aug 2007
Posts: 5

PostPosted: Tue Jan 22, 2008 11:08 pm    Post subject: Insert standard text into a new message Reply with quote

Hello,

I am pretty new at this but, how do you insert standard text into a new
e-mail message without deleting the default signature? I am using the
following code:


Sub Macro1()
Set OutLk = CreateObject("Outlook.Application")
Set Email = OutLk.CreateItem(0)
With Email
..To = "me@msn.com"
..Subject = "New Message"
..Body = "Hello?"
..Display
End With
Set Email = Nothing
Set OutLk = Nothing
End Sub

Archived from group: microsoft>public>outlook>program_vba
Back to top
View user's profile Send private message
JP



Joined: 21 Nov 2007
Posts: 33

PostPosted: Wed Jan 23, 2008 12:57 am    Post subject: Re: Insert standard text into a new message Reply with quote

Try

.Body = "Hello?" & .Body



HTH,
JP

On Jan 22, 9:08 pm, Gabe wrote:
> Hello,
>
> I am pretty new at this but, how do you insert standard text into a new
> e-mail message without deleting the default signature? I am using the
> following code:
>
> Sub Macro1()
> Set OutLk = CreateObject("Outlook.Application")
> Set Email = OutLk.CreateItem(0)
> With Email
> .To = "m...@msn.com"
> .Subject = "New Message"
> .Body = "Hello?"
> .Display
> End With
> Set Email = Nothing
> Set OutLk = Nothing
> End Sub
Back to top
View user's profile Send private message
Gabe



Joined: 12 Aug 2007
Posts: 5

PostPosted: Wed Jan 23, 2008 1:26 pm    Post subject: Re: Insert standard text into a new message Reply with quote

No, a message box came up that said (A program is trying to access e-mail
addresses you have stored in Outlook. Do you want tp allow this?

If this is unexpected, it may be a virus and you should choose "No".)

So when I click on No it does nothing, when I click on Yes it works but the
signature is still deleted?

Any alternatives to this problem?



"JP" wrote:

> Try
>
> .Body = "Hello?" & .Body
>
>
>
> HTH,
> JP
>
> On Jan 22, 9:08 pm, Gabe wrote:
> > Hello,
> >
> > I am pretty new at this but, how do you insert standard text into a new
> > e-mail message without deleting the default signature? I am using the
> > following code:
> >
> > Sub Macro1()
> > Set OutLk = CreateObject("Outlook.Application")
> > Set Email = OutLk.CreateItem(0)
> > With Email
> > .To = "m...@msn.com"
> > .Subject = "New Message"
> > .Body = "Hello?"
> > .Display
> > End With
> > Set Email = Nothing
> > Set OutLk = Nothing
> > End Sub
>
>
Back to top
View user's profile Send private message
JP



Joined: 21 Nov 2007
Posts: 33

PostPosted: Wed Jan 23, 2008 1:32 pm    Post subject: Re: Insert standard text into a new message Reply with quote

You didn't mention the Outlook version. If you want to insert your
signature programmatically

In OL2007: http://www.outlookcode.com/codedetail.aspx?id=1743

Otherwise: http://www.outlookcode.com/codedetail.aspx?id=615


HTH,
JP

On Jan 23, 11:26 am, Gabe wrote:
> No, a message box came up that said (A program is trying to access e-mail
> addresses you have stored in Outlook. Do you want tp allow this?
>
> If this is unexpected, it may be a virus and you should choose "No".)
>
> So when I click on No it does nothing, when I click on Yes it works but the
> signature is still deleted?
>
> Any alternatives to this problem?
>
>
>
> "JP" wrote:
> > Try
>
> > .Body = "Hello?" & .Body
>
> > HTH,
> > JP
>
> > On Jan 22, 9:08 pm, Gabe wrote:
> > > Hello,
>
> > > I am pretty new at this but, how do you insert standard text into a new
> > > e-mail message without deleting the default signature? I am using the
> > > following code:
>
> > > Sub Macro1()
> > > Set OutLk = CreateObject("Outlook.Application")
> > > Set Email = OutLk.CreateItem(0)
> > > With Email
> > > .To = "m...@msn.com"
> > > .Subject = "New Message"
> > > .Body = "Hello?"
> > > .Display
> > > End With
> > > Set Email = Nothing
> > > Set OutLk = Nothing
> > > End Sub- Hide quoted text -
>
> - Show quoted text -
Back to top
View user's profile Send private message
Sue Mosher [MVP-Outlook]



Joined: 12 Aug 2007
Posts: 656

PostPosted: Wed Jan 23, 2008 4:44 pm    Post subject: Re: Insert standard text into a new message Reply with quote

Where are you writing this macro? In Outlook or another application?

See http://www.outlookcode.com/article.aspx?ID=52 for information on the security prompts.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Gabe" wrote in message @microsoft.com...
> No, a message box came up that said (A program is trying to access e-mail
> addresses you have stored in Outlook. Do you want tp allow this?
>
> If this is unexpected, it may be a virus and you should choose "No".)
>
> So when I click on No it does nothing, when I click on Yes it works but the
> signature is still deleted?
>
> Any alternatives to this problem?
>
>
>
> "JP" wrote:
>
>> Try
>>
>> .Body = "Hello?" & .Body
>>
>>
>>
>> HTH,
>> JP
>>
>> On Jan 22, 9:08 pm, Gabe wrote:
>> > Hello,
>> >
>> > I am pretty new at this but, how do you insert standard text into a new
>> > e-mail message without deleting the default signature? I am using the
>> > following code:
>> >
>> > Sub Macro1()
>> > Set OutLk = CreateObject("Outlook.Application")
>> > Set Email = OutLk.CreateItem(0)
>> > With Email
>> > .To = "m...@msn.com"
>> > .Subject = "New Message"
>> > .Body = "Hello?"
>> > .Display
>> > End With
>> > Set Email = Nothing
>> > Set OutLk = Nothing
>> > End Sub
>>
>>
Back to top
View user's profile Send private message
Gabe



Joined: 12 Aug 2007
Posts: 5

PostPosted: Wed Jan 23, 2008 1:49 pm    Post subject: Re: Insert standard text into a new message Reply with quote

Sorry about that I am running 2003, I tried all the code in that link but it
doesn't seem to work? Also, is there a way to set a default SigName? Because
I am not the only one who will be using this code...

I am really kinda of new at all this, thank you so much for your help.

"JP" wrote:

> You didn't mention the Outlook version. If you want to insert your
> signature programmatically
>
> In OL2007: http://www.outlookcode.com/codedetail.aspx?id=1743
>
> Otherwise: http://www.outlookcode.com/codedetail.aspx?id=615
>
>
> HTH,
> JP
>
> On Jan 23, 11:26 am, Gabe wrote:
> > No, a message box came up that said (A program is trying to access e-mail
> > addresses you have stored in Outlook. Do you want tp allow this?
> >
> > If this is unexpected, it may be a virus and you should choose "No".)
> >
> > So when I click on No it does nothing, when I click on Yes it works but the
> > signature is still deleted?
> >
> > Any alternatives to this problem?
> >
> >
> >
> > "JP" wrote:
> > > Try
> >
> > > .Body = "Hello?" & .Body
> >
> > > HTH,
> > > JP
> >
> > > On Jan 22, 9:08 pm, Gabe wrote:
> > > > Hello,
> >
> > > > I am pretty new at this but, how do you insert standard text into a new
> > > > e-mail message without deleting the default signature? I am using the
> > > > following code:
> >
> > > > Sub Macro1()
> > > > Set OutLk = CreateObject("Outlook.Application")
> > > > Set Email = OutLk.CreateItem(0)
> > > > With Email
> > > > .To = "m...@msn.com"
> > > > .Subject = "New Message"
> > > > .Body = "Hello?"
> > > > .Display
> > > > End With
> > > > Set Email = Nothing
> > > > Set OutLk = Nothing
> > > > End Sub- Hide quoted text -
> >
> > - Show quoted text -
>
>
Back to top
View user's profile Send private message
Gabe



Joined: 12 Aug 2007
Posts: 5

PostPosted: Wed Jan 23, 2008 1:54 pm    Post subject: Re: Insert standard text into a new message Reply with quote

Sorry, in Outlook 2003.

"Sue Mosher [MVP-Outlook]" wrote:

> Where are you writing this macro? In Outlook or another application?
>
> See http://www.outlookcode.com/article.aspx?ID=52 for information on the security prompts.
>
> --
> Sue Mosher, Outlook MVP
> Author of Microsoft Outlook 2007 Programming:
> Jumpstart for Power Users and Administrators
> http://www.outlookcode.com/article.aspx?id=54
>
>
> "Gabe" wrote in message @microsoft.com...
> > No, a message box came up that said (A program is trying to access e-mail
> > addresses you have stored in Outlook. Do you want tp allow this?
> >
> > If this is unexpected, it may be a virus and you should choose "No".)
> >
> > So when I click on No it does nothing, when I click on Yes it works but the
> > signature is still deleted?
> >
> > Any alternatives to this problem?
> >
> >
> >
> > "JP" wrote:
> >
> >> Try
> >>
> >> .Body = "Hello?" & .Body
> >>
> >>
> >>
> >> HTH,
> >> JP
> >>
> >> On Jan 22, 9:08 pm, Gabe wrote:
> >> > Hello,
> >> >
> >> > I am pretty new at this but, how do you insert standard text into a new
> >> > e-mail message without deleting the default signature? I am using the
> >> > following code:
> >> >
> >> > Sub Macro1()
> >> > Set OutLk = CreateObject("Outlook.Application")
> >> > Set Email = OutLk.CreateItem(0)
> >> > With Email
> >> > .To = "m...@msn.com"
> >> > .Subject = "New Message"
> >> > .Body = "Hello?"
> >> > .Display
> >> > End With
> >> > Set Email = Nothing
> >> > Set OutLk = Nothing
> >> > End Sub
> >>
> >>
>
Back to top
View user's profile Send private message
JP



Joined: 21 Nov 2007
Posts: 33

PostPosted: Wed Jan 23, 2008 2:21 pm    Post subject: Re: Insert standard text into a new message Reply with quote

This code worked for me. I put this code in a standard Outlook module.
You mentioned the security prompt, if you are using this in Outlook
that won't happen. Unfortunately the code changes the formatting of
the signature, a small price to pay.


Sub Macro1()

Dim olApp As Outlook.Application
Dim olMsg As Outlook.MailItem

Set olApp = Outlook.Application
Set olMsg = olApp.CreateItem(olMailItem)

With olMsg
.To = "someone@somewhere.com"
.Subject = "Hello world"
.Display
.Body = "Hello, here is my email!" & .Body
End With

Set olMsg = Nothing
Set olApp = Nothing
End Sub


HTH,
JP

On Jan 23, 11:49 am, Gabe wrote:
> Sorry about that I am running 2003, I tried all the code in that link but it
> doesn't seem to work? Also, is there a way to set a default SigName? Because
> I am not the only one who will be using this code...
>
> I am really kinda of new at all this, thank you so much for your help.
>
>
>
Back to top
View user's profile Send private message
Gabe



Joined: 12 Aug 2007
Posts: 5

PostPosted: Thu Jan 24, 2008 1:55 pm    Post subject: Re: Insert standard text into a new message Reply with quote

Yes! that did it! your a genius! Thanks a bunch!

"JP" wrote:

> This code worked for me. I put this code in a standard Outlook module.
> You mentioned the security prompt, if you are using this in Outlook
> that won't happen. Unfortunately the code changes the formatting of
> the signature, a small price to pay.
>
>
> Sub Macro1()
>
> Dim olApp As Outlook.Application
> Dim olMsg As Outlook.MailItem
>
> Set olApp = Outlook.Application
> Set olMsg = olApp.CreateItem(olMailItem)
>
> With olMsg
> .To = "someone@somewhere.com"
> .Subject = "Hello world"
> .Display
> .Body = "Hello, here is my email!" & .Body
> End With
>
> Set olMsg = Nothing
> Set olApp = Nothing
> End Sub
>
>
> HTH,
> JP
>
> On Jan 23, 11:49 am, Gabe wrote:
> > Sorry about that I am running 2003, I tried all the code in that link but it
> > doesn't seem to work? Also, is there a way to set a default SigName? Because
> > I am not the only one who will be using this code...
> >
> > I am really kinda of new at all this, thank you so much for your help.
> >
> >
> >
>
Back to top
View user's profile Send private message
JP



Joined: 21 Nov 2007
Posts: 33

PostPosted: Thu Jan 24, 2008 7:05 pm    Post subject: Re: Insert standard text into a new message Reply with quote

Glad to hear it worked!


Thx,
JP

On Jan 24, 11:55 am, Gabe wrote:
> Yes! that did it! your a genius! Thanks a bunch!
>
>
>
> "JP" wrote:
> > This code worked for me. I put this code in a standard Outlook module.
> > You mentioned the security prompt, if you are using this in Outlook
> > that won't happen. Unfortunately the code changes the formatting of
> > the signature, a small price to pay.
>
> > Sub Macro1()
>
> > Dim olApp As Outlook.Application
> > Dim olMsg As Outlook.MailItem
>
> > Set olApp = Outlook.Application
> > Set olMsg = olApp.CreateItem(olMailItem)
>
> > With olMsg
> >    .To = "some...@somewhere.com"
> >    .Subject = "Hello world"
> >    .Display
> >     .Body = "Hello, here is my email!" & .Body
> > End With
>
> > Set olMsg = Nothing
> > Set olApp = Nothing
> > End Sub
>
> > HTH,
> > JP

Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
Programmatic plain-text insert I would like to create a macro, and put it on a toolbar button, that invoked the behavior of Edit>Paste text. How do I insert in an email that is open? Can macros be assigned to buttons on a toolbar? -- There are exactly 10 kinds of peopl

VBA code to put standard string into body of exisiting task I want to make a script that puts standard textstring into the body of an open task. I have found a lot on the internet about the subject, but they all create a new task. I only want to automate a standard string (like date and name) into the bodyof an op

printing custom forms with user defined and standard fields Help. I am so proud of myself because I have managed to create a custom form and print it out beautifully by inserting a VSB script and linking it to Word. The only problem is that all of my user-defined fields print correctly .. . but I can't get the T

Consolidate Mail text Can someone please help me write a macro to consolidate text from several mails and put it in a single mail ?

Rule print message does not work with encrypted message! Is there a way to create a rule to print incomming emails that are encrypted? If I use a rule and an encrypted email commes in I get the error message: "This digitaly signed email cannot be opened in an UI-less mode". I have a lot of encrypted emails comm
Post new topic   Reply to topic    msoutlook.org Forum Index -> Outlook Program VBA All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group