Fixed font Subject: Start macro creating a mail with contact data and autotext
Author: WaWa Date: 24 Feb 2009
References:
Hallo,



I am working with an user form.

The developing of that form started with Outlook XP with a lot of code
inside for different buttons.



I changed to Outlook 2007 and unfortunately the code of the form was not
longer displayed.



What I learned about this is that MS does not support to much code in the
form (or maybe a bug).

They also do not support any longer.

I was sending this form to MS support but they told it is do much code
inside and they do not know, why the code is not displayed.



In Outlook 2003 the code is displayed as in Outlook XP.



Because I do not know really how to program a user form (I put it together
with some codes I found in Internet and with the help of Newsgroups) I
thought maybe the code is the reason why it is no longer displayed in
Outlook 2007.



So I started to develop the form from beginning in Outlook 2007.



Everything worked fine, but when it comes to too much code for the 12
buttons the same thing (code is no longer displayed) happened.



I could not find out if the reason is the number of lines or characters, in
fact if I put more code inside (more lines than 140) it is not displayed.



Concerning the above I have the following questions:





1. Is there another possibility to display and edit the code I only
know the steps - develop a form, -display code.



2. If not there is the idea to write in the code ...



and start a macro instead of writing the code in the form.
Therefore I created a macro called "Mail1", is placed in Modul1, with the
following content:
Sub Mail1()



Dim Nachricht

Dim Adresse

Dim Text

Set Nachricht = Application.CreateItem(olMailItem)

Set Item = ActiveInspector.CurrentItem

Nachricht.Subject = "Subject"

Nachricht.To = Item.Email1Address

Adresse = Item.CompanyName + vbCr

Adresse = Adresse + Item.BusinessAddressStreet + vbCr

Adresse = Adresse + Item.BusinessAddressPostalCode + " "

Adresse = Adresse + Item.BusinessAddressCity + vbCr + vbCr

Adresse = Adresse + Item.Title + " " + Item.LastName + vbCr + vbCr

Nachricht.Body = Adresse



Nachricht.Categories = "Geschäftlich"

Nachricht.Importance = olImportanceNormal

'Nachricht.Send

Nachricht.Display

End Sub




With a button called .
Sub CommandButton1_Click

Application.Mail1()

End Sub

'---

Private Sub CommandButton2_Click

Mail1

End Sub

'---

Private Sub CommandButton3_Click

Mail1()

End Sub

'---

Private Sub CommandButton4_Click

call Mail1()

End Sub

'---

Private Sub CommandButton5_Click

call Mail1

End Sub

'---

Private Sub CommandButton6_Click

run Mail1

End Sub

'---

Sub CommandButton7_Click

Application.Mail1

End Sub

'---


I try to start this macro, without success.
If I open a contact with my form a call the macro with Outlook commands, the
macro is working.



Please can anyone tell me how to call the macro and where the macro should
be placed?

Modul1,

This Outlook session?

Sub?

Private Sub?

Function?



3. The macro is creating a new email, fills in the contacts email
address and in the body the contact data.



Now I want to fill in an autotext below the address data.



I think that could be done in reading the autotext in a variable and put it
in the body like body = body + variable.



I do not want to create a menu entry or buttons in the toolbar and not only
open a mail item and choose the autotext entries from the menu.



It would be great if anybody can help me to make my button in the form alive
to call the macro.



WaWa



p.s. Windows Vista with all Windows updates, Outlook 2007 with all Office
updates. Macro security set to NO. I am not sure whether all necessary
libraries are enabled. It is a standard office installation.