VBA & Outlook 2007

Status
Not open for further replies.
Outlook version
Outlook 2007
Email Account
POP3
I have used vba with EXCEL extensively but want to write a small macro / script that operates from a RULE in Outlook. Simply check all incoming mail and if 'something' is in subject line then execute - i.e. extract data from body and write to a txt file for processing elsewhere.

I have ammended the Additional controls to include (i.e. a cross against it) anything starting with 'Microsoft Office Outlook'. I have changed the Trust Centre , macro security 'Check all macros - i.e. 3rd down in list. I have placed a 'breakpoint' against a first statement 'int1=1' in my code.

I now create a message with the appropriate header and send to myself, the message arrives but the script / macro breakpoint is not actioned and nothing appears to happen.

If I try and manually run the macro than I struggle

Tools, Macros - nothing in the main body and at the bottom of the screen
Macros in - Project1(VbaProject.OTM)

So I goto Tools , Visual Basic Editor
I can see the code but if I highlight the first line and DEBUG then I get the same blank list of Macros

Sound like something pretty basic. The code was for test purposes only.

Code:
Sub A1(MyMail As MailItem)
'=============================================creates email message
Dim int1 As Integer, int2 As Integer
Dim strID As String
Dim objMail As Outlook.MailItem
Dim str1 As String, str2 As String, str3 As String, str4 As String
Dim mailcontent As String
    int1 = 1
    str1 = "Hello"
    strID = MyMail.EntryID
    'Set objMail = Application.Session.GetItemFromID(strID)
    'objMail.BodyFormat = olFormatPlain
    'objMail.Save
    mailcontent = objMail.Body
    CreateMessage "my email address", "loads of interesting stuff" + vbCrLf + mailcontent, "My Subject Title"
    Set objMail = Nothing
End Sub

Sub CreateMessage(mailaddress As String, mailcontent As String, mailsubject As String)
    Set myOlApp = CreateObject("Outlook.Application")
    Set myitem = myOlApp.CreateItem(olMailItem)
    'Set myRecipient = myitem.Recipients.Add(mailaddress)  // or
    myitem.Recipients.Add (mailaddress)
    myitem.Subject = mailsubject
    myitem.Body = mailcontent
    myitem.Display
    myitem.Send
End Sub
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
After lowering the security settings, restart Outlook. Does that help?

Only macros that don't expect parameters can be run manually, other aren't visible in the mentioned list of macros. So if you want to test it, call it by another macro:
Code:
public sub starta1()
a1 application.activeexplorer.selection(1)
end sub
 
Outlook version
Outlook 2007
Email Account
POP3
Michael,

Many thanks - have been 'playin' and managed to achieve some results.

Seems like a 'macro' that appears in the macro list has no parameters (as stated) and these are the only routines listed in the available scripts when creating a Rule.

Thanks again
 
Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date
P Outlook 2007 Email Categorization using VBA Outlook VBA and Custom Forms 1
J Outlook 2007 Rules & VBA: How to run a script on a report message (ReportItem) Using Outlook 14
O For Outlook 2007 - VBA to print attachments Using Outlook 1
M Updating VBA code from outlook 2007 to outlook 2010 Using Outlook 1
J Creating Tasks in Outlook 2007 with VBA Outlook VBA and Custom Forms 1
M vba in outlook 2007 Outlook VBA and Custom Forms 5
L List of Calender Fields for VBA (Outlook 2007) Outlook VBA and Custom Forms 1
R Outlook 2003/2007 Rule and Conditions for InBox VBA customization Outlook VBA and Custom Forms 3
M Outlook 2013 reminder email by using Outlook vba Outlook VBA and Custom Forms 2
D Outlook VBA error extracting property data from GetRules collection Outlook VBA and Custom Forms 10
O Email not leaving Outbox when using Excel VBA to sync Outlook account Outlook VBA and Custom Forms 4
L Moving emails with similar subject and find the timings between the emails using outlook VBA macro Outlook VBA and Custom Forms 1
B Outlook Business Contact Manager with SQL to Excel, User Defined Fields in BCM don't sync in SQL. Can I use VBA code to copy 1 field to another? BCM (Business Contact Manager) 0
N How can I increase/faster outlook VBA Macro Speed ? Using Outlook 2
N Outlook Email Rule execution through shortcut keys (VBA codes) Using Outlook 1
A VBA Code in Outlook disappears after first use Outlook VBA and Custom Forms 1
dweller Outlook 2010 Rule Ignores VBA Script Outlook VBA and Custom Forms 2
G Outlook VBA and Google Calendar ("Events") Outlook VBA and Custom Forms 1
J VBA Outlook : Subject line : Cut and Paste name to heading , number to very end of the body of Email Outlook VBA and Custom Forms 1
B Advanced Search in MS Outlook by VBA and SQL Outlook VBA and Custom Forms 2
K Outlook Archive to PST Files by Date Range VBA Script? Outlook VBA and Custom Forms 1
J Help Please!!! Outlook 2016 - VBA Macro for replying with attachment in meeting invite Outlook VBA and Custom Forms 9
S Find a cell value in excel using outlook vba Using Outlook 1
J Execute Add-In Button from VBA Outlook 2016 Outlook VBA and Custom Forms 1
J Open an outlook email by Subject on MS Access linked table with VBA Outlook VBA and Custom Forms 10
D create an html table in outlook custom form 2010 using vba in MsAccess Outlook VBA and Custom Forms 7
M Slow VBA macro in Outlook Outlook VBA and Custom Forms 5
T Outlook AntiSpam with VBA Outlook VBA and Custom Forms 1
F "Move to" O365 feature to Outlook client via VBA Outlook VBA and Custom Forms 4
B query outlook using vba Outlook VBA and Custom Forms 13
J VBA to switch Outlook online/offline Outlook VBA and Custom Forms 4
M VBA to change flag status in outlook contact item Outlook VBA and Custom Forms 3
T VBA outlook, detect priority emails Outlook VBA and Custom Forms 5
C Need VBA code to automatically save message outside outlook and add date Outlook VBA and Custom Forms 1
stephen li VBA Outlook send mail automatically by specified outlook mail box Outlook VBA and Custom Forms 1
S Outlook VBA Contacts Notes Outlook VBA and Custom Forms 0
O VBA to Run Font Change on Outlook Startup Outlook VBA and Custom Forms 4
O VBA or other solution for Outlook tasks to OneNote Outlook VBA and Custom Forms 0
S Automatically selecting folders and deleting messages in Outlook VBA Outlook VBA and Custom Forms 7
D Creating an outlook session from Access vba but run silently. With A specific profile Outlook VBA and Custom Forms 1
Diane Poremsky Outlook VBA: Use a Text File to Populate a ListBox New Slipstick.com Articles 0
C Saving Outlook attachments and links to attachments with VBA Outlook VBA and Custom Forms 2
Diane Poremsky Outlook VBA: Work with Open Item or Selected Item New Slipstick.com Articles 0
Diane Poremsky Working with VBA and non-default Outlook Folders New Slipstick.com Articles 0
C Outlook VBA to set current account Outlook VBA and Custom Forms 1
Diane Poremsky Use VBA to create an Outlook Search Folder for Sender New Slipstick.com Articles 0
F VBA routine to write new sub routine in outlook Outlook VBA and Custom Forms 0
D Change sender name outlook vba 2010 Custom Userform Outlook VBA and Custom Forms 1
G Adding a contact to Outlook with a custom form using Access VBA Outlook VBA and Custom Forms 1
C Outlook 2016 - converting Word VBA to default Outlook message Outlook VBA and Custom Forms 0
Similar threads


















































Top