|
Answer» Hello Members,
I do not use Macros but recently I have tried to create a Macro in OUTLOOK 2000, It is a simple "Mail" macro.
I am try to create a Macro that will simply reply to an email message with a few sentences. Can someone help me create an "email macro" that simple automatically types a message in the "body" of the message. I spent most of the day on google, but the only macro I found was the one below. which only adds a message to the "subject" area. I would like to add a message also to the "body" of the mail message as well, but do not understand to do it. Can someone please explain how to create a "mail" macro in Outlook 2000 for beginners like myself. Here is a Macro I found on google, but it only adds one line in the subject area: Thankyou all for your help., Ric
Sub HelloWorldMessage() Dim msg As Outlook.MailItem Set msg = Application.CreateItem(olMailItem) msg.Subject = "Hello World!" msg.Display Set msg = Nothing End SubYou might try using the body property in the mailitem class:
Code: [Select]Sub HelloWorldMessage() Dim msg As Outlook.MailItem Set msg = Application.CreateItem(olMailItem) msg.Body = "Hello World!" msg.Display Set msg = Nothing End Sub
Good luck. Hello and thankyou,
This worked for me, I can't thankyou enough. Could you help me a bit further,
I also wanted to add back the "subject" line, so the macro would contain "both" the subject like and the "body". Could you show me what that code would look like and then I could paste it in.
P.S. The text that I am writing in the body, when I press the macro button, turns out to be "two long lines", is there any way to make the macro format the text as follows instead of two long lines:
Dear Personnel,
Thankyou for the opportunity to respond to your help desk position, I look forward to meeting with you and your staff to discuss my qualifications.
Sincerely, Richard (Is there anyway to format the text in the macro to look like this paragraph, RIGHT now everything is put into just two lines without any wrapping or FORMATTING. thankyou again ! rickThe key is to do the formatting yourself:
Code: [Select]Sub HelloWorldMessage() Dim msg As Outlook.MailItem Set msg = Application.CreateItem(olMailItem) msg.Subject = "Hello World!"
str = "Dear Personnel," & vbCrLf & vbCrLf str = str & "THANK you for the opportunity to respond to your help desk position," & vbCrLf str = str & "I look forward to meeting with you and your staff to discuss my qualifications." & vbCrLf & vbCrLf str = str & "Sincerely," & vbCrLf str = str & "Richard" msg.Body = str
msg.Display Set msg = Nothing End Sub
Hope this helps.
The code is untested, but this should give you some ideas.Hello,
I tried to run the "code you mentioned" and I received the error message "Compile error: Argument not optional".
a little yellow arrow was pointing to the very first line where is says:
Sub HelloworldMessage () which was all in "yellow color
Also the first "Str = "Dear Personel," etc
The "str" was blue. on that first line.
I didn't like to bother you, thankyou for your help, if you have time to get just this one macro working that would be all I need, I would like make my own macros but do not understand the help file that came with the VBA, so I will read up on understanding how to create a macro with VBA.
If you would be kind enough to get this one macro working that would be great, perhaps I am doing something wrong, I just simply pasted everything into the Project where it said "this outlook session" as you mentioned before. I then saved it, and then ran the macro, but received error. Thankyou again for your help. Ric Forgot about declaring variables.
Code: [Select]Sub HelloWorldMessage() Dim msg As Outlook.MailItem Dim str as String Set msg = Application.CreateItem(olMailItem) msg.Subject = "Hello World!"
str = "Dear Personnel," & vbCrLf & vbCrLf str = str & "Thank you for the opportunity to respond to your help desk position," & vbCrLf str = str & "I look forward to meeting with you and your staff to discuss my qualifications." & vbCrLf & vbCrLf str = str & "Sincerely," & vbCrLf str = str & "Richard" msg.Body = str
msg.Display Set msg = Nothing End Sub
Not sure about this line: "Str = "Dear Personel,". The posted code shows no leading quote on Str. Quotes should come in pairs.
Basically you're creating a long string with well placed carriage returns/line feeds to make it look formatted.
Thankyou, Thankyou and Thankyou !!
It worked perfectly ! Exactly what I wanted. I appreciate your generous and patient help, you've helped me more than I can say.
I'll be sending out a lot of resumes, and these macros will automate everything and save me a lot of typing time, macros are really quite incredible.
I tried to "Save the Macro" to a "Button" on the tool bar, by pressing "customize" on the toolbar. And although the "macro" button that I want to use stays there for the first session. Whenever I "reboot" or "close" the Outlook program. IT COMPLETELY DISAPPEARS. I am using Outlook 2000, iS THIS A "BUG" in the program. I've tried saving the macro shortcut button to the toolbar at least 10 times, and the "button" on the toolbar is completely gone the next time I start up Outllook. Have you heard of anything like this problem.? Now that Ihave this great macro, it would be even faster to press a button on the toolbar to activate it, instead of going to "Tools >Macro>Macro.name Thankyou again. This will work on Outlook 2002, should be the same for 2000:
Create the macro
View==>TOOLBARS==>Customize==>New
Add new toolbar
Click Commands Tab
Click the name of the toolbar you just added
From the right panel, drag the macro name to the newly created toolbar
Note: the new toolbar is not docked. Try moving on to the Outlook toolbar if you prefer.
Good luck. Please try to keep your posts together in one thread. I cannot duplicate your problem with attaching the macro to a toolbar. Perhaps it is unique to Outlook 2000.
However, there are other ways of sending mail. The following script runs external to the Outlook application but still utilizes Outlook's properties and methods. Nice thing is the outgoing mail is preserved in your sent items folder.
Code: [Select]Const olMailItem = 0
Set ol = CreateObject("Outlook.Application") Set oMail = ol.CreateItem(olMailItem)
With oMail .To = "[emailprotected]" .Subject = "Hello World!"
str = "Dear Personnel," & vbCrLf & vbCrLf str = str & "Thank you for the opportunity to respond to your help desk position," & vbCrLf str = str & "I look forward to meeting with you and your staff to discuss my qualifications." & vbCrLf & vbCrLf str = str & "Sincerely," & vbCrLf str = str & "Richard" .Body = str .Attachments.Add("c:\documents\resume.doc") .Send End With
ol.Quit
Be sure to fixup the To address and the path to resume.doc. Save script with a vbs extension and run from the command line as wscript scriptname.vbs
Then there is a command line program called blat. Finally, there is a scriptable object called CDO.Message. Neither of these two will automatically create entries in your Outlook send items folder.Thanks, I will keep my posts together in one string, appreciate your help, I'm sure this will work FINE, and yes it might be just isolated problem with the button on outlook 2000, I would like to upgrade if Ican. Thankyou again for your kind help, RicHi,
Do you know of any good sites where I can download some helpful Macros for my work. I've found out that "macros" are quite incredible tools. Is there a site where I can download a variety of sample macros that can do a variety of different useful tasks . Thanks , RicHi
I have been also studying for my MCP cert,, and have created over 35 separate Word .docx and .doc study files, a mixture of both, most are word 2007 . I am trying to create a MACRO that will combine or append all of these or at least most of them into 1 .DOCX OR .DOC FILE. So I will have one large Ebook, so to speak to study from.
Can I have help to create a Macro that will Append all these files: I have for example. Doc1, Doc2, Doc3, Doc4, Doc5, etc and I want to combine OR append them into just one MAIN.DOC . or MAIN.DOCX file
Thankyou all, Ric
|