How to launch macro within a rule?

Status
Not open for further replies.
M

mntn-biker

Newbie here and have virtually no vba experience but have a hopefully

simple question. Is it possible to launch a macro within a rule in

Outlook 2003? Here is the macro that I want to launch when I receive an

e-mail from a customer:

Sub txtmsgfw()

Dim msg As Outlook.MailItem

Set msg = Application.CreateItem(olMailItem)

msg.Subject = "Email from Customer"

msg.Display

Set msg = Nothing

End Sub

I am using the rule to create a new simple e-mail message that I can

have forwarded to my cell phone as a text message. I cannot simply use

forwarding since some e-mails from my customers have 8mb attachments and

those don't fly. I don't see anyplace within the rules that can launch

a macro unless I am missing it.

Thanks - Mike

mntn-biker

----------------------------------------mntn-biker's Profile: userid=312
?t=96641
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
There's just a simple change necessary as the rule needs to pass the mail

from the customer the the rule:

Sub txtmsgfw(Mail As Outlook.MailItem)

Dim msg As Outlook.MailItem

Set msg = Application.CreateItem(olMailItem)

msg.Subject = "Email from Customer"

msg.Display

Set msg = Nothing

End Sub

Best regards

Michael Bauer

Am Thu, 14 May 2009 16:43:36 +0100 schrieb mntn-biker:


> Newbie here and have virtually no vba experience but have a hopefully
> simple question. Is it possible to launch a macro within a rule in
> Outlook 2003? Here is the macro that I want to launch when I receive an
> e-mail from a customer:

> Sub txtmsgfw()
> Dim msg As Outlook.MailItem
> Set msg = Application.CreateItem(olMailItem)
> msg.Subject = "Email from Customer"
> msg.Display
> Set msg = Nothing
> End Sub

> I am using the rule to create a new simple e-mail message that I can
> have forwarded to my cell phone as a text message. I cannot simply use
> forwarding since some e-mails from my customers have 8mb attachments and
> those don't fly. I don't see anyplace within the rules that can launch
> a macro unless I am missing it.

> Thanks - Mike
 
M

mntn-biker

'Michael Bauer [MVP - Outlook Wrote:
> ;345545']There's just a simple change necessary as the rule needs to
> pass the mail
> from the customer the the rule:

> Sub txtmsgfw(Mail As Outlook.MailItem)
> Dim msg As Outlook.MailItem
> Set msg = Application.CreateItem(olMailItem)
> msg.Subject = "Email from Customer"
> msg.Display
> Set msg = Nothing
> End Sub

> > Best regards
> Michael Bauer

>

> Am Thu, 14 May 2009 16:43:36 +0100 schrieb mntn-biker:
>
> > Newbie here and have virtually no vba experience but have a

> hopefully
> > simple question. Is it possible to launch a macro within a rule in
> > Outlook 2003? Here is the macro that I want to launch when I receive

> an
> > e-mail from a customer:
> > Sub txtmsgfw()
> > Dim msg As Outlook.MailItem
> > Set msg = Application.CreateItem(olMailItem)
> > msg.Subject = "Email from Customer"
> > msg.Display
> > Set msg = Nothing
> > End Sub
> > I am using the rule to create a new simple e-mail message that I can
> > have forwarded to my cell phone as a text message. I cannot simply

> use
> > forwarding since some e-mails from my customers have 8mb attachments

> and
> > those don't fly. I don't see anyplace within the rules that can

> launch
> > a macro unless I am missing it.
> > Thanks - Mike


Maybe I am missing something but shouldn't I be selecting something

from within this window to get my original macro to launch?

[image: http://www.premiertooldesign.com/images/tech/ol2003rule.gif]

mntn-biker

----------------------------------------mntn-biker's Profile: userid=312
?t=96641
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
Excactly. If the shown script is in the ThisOutlookSession module, you

should be able to select it.

Best regards

Michael Bauer

Am Thu, 14 May 2009 18:37:25 +0100 schrieb mntn-biker:


> 'Michael Bauer [MVP - Outlook Wrote:
> > ;345545']There's just a simple change necessary as the rule needs to
> > pass the mail
> > from the customer the the rule:
>

>> Sub txtmsgfw(Mail As Outlook.MailItem)
> > Dim msg As Outlook.MailItem
> > Set msg = Application.CreateItem(olMailItem)
> > msg.Subject = "Email from Customer"
> > msg.Display
> > Set msg = Nothing
> > End Sub
>

>> > > Best regards
> > Michael Bauer
>

>>>>>
>
>
>> Am Thu, 14 May 2009 16:43:36 +0100 schrieb mntn-biker:
> >
> >> Newbie here and have virtually no vba experience but have a

> > hopefully
> >> simple question. Is it possible to launch a macro within a rule in
> >> Outlook 2003? Here is the macro that I want to launch when I receive

> > an
> >> e-mail from a customer:
> >
>>> Sub txtmsgfw()
> >> Dim msg As Outlook.MailItem
> >> Set msg = Application.CreateItem(olMailItem)
> >> msg.Subject = "Email from Customer"
> >> msg.Display
> >> Set msg = Nothing
> >> End Sub
> >
>>> I am using the rule to create a new simple e-mail message that I can
> >> have forwarded to my cell phone as a text message. I cannot simply

> > use
> >> forwarding since some e-mails from my customers have 8mb attachments

> > and
> >> those don't fly. I don't see anyplace within the rules that can

> > launch
> >> a macro unless I am missing it.
> >
>>> Thanks - Mike


> Maybe I am missing something but shouldn't I be selecting something
> from within this window to get my original macro to launch?

> [image: http://www.premiertooldesign.com/images/tech/ol2003rule.gif]
 
M

mntn-biker

Michael - Thanks for your help and patience thus far. I have attempted

to paste the code into ThisOutlookSession (please see image below).

When I click on script in the rule window, nothing shows up here. I

have changed the macro security to medium. Do I not have something

correct in the ThisOutlookSession window?

[image: http://www.premiertooldesign.com/images/tech/ol2003rule2.gif]

mntn-biker

----------------------------------------mntn-biker's Profile: userid=312
?t=96641
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
Delete the code from modul1, and turn the code in ThisoutlookSession from

Private to Public. Does that help?

Best regards

Michael Bauer

Am Fri, 15 May 2009 19:05:42 +0100 schrieb mntn-biker:


> Michael - Thanks for your help and patience thus far. I have attempted
> to paste the code into ThisOutlookSession (please see image below).
> When I click on script in the rule window, nothing shows up here. I
> have changed the macro security to medium. Do I not have something
> correct in the ThisOutlookSession window?

> [image: http://www.premiertooldesign.com/images/tech/ol2003rule2.gif]
 
M

mntn-biker

Michael - Thanks! That got me thru that first part. Now I have been

messing with adding a recipient and making it send. Here is my code

(that does not work - see image below):

Public Sub txtmsgfw(Mail As Outlook.MailItem)

Dim msg As Outlook.MailItem

Dim Recip As Outlook.Recipient

Set msg = Application.CreateItem(olMailItem)

msg.Subject = "Email from customer"

Set Recip = .Recipients.Add("myname@domain.com")

Recip.Type = olTo

For Each Recip In .Recipients

If Not Recip.Resolve Then

msg.Display

Set msg = Nothing

End If

Next

> Send

End Sub

Any ideas?????

Thanks again for your help! I have been able to read thru the code to

understand what it is doing however, I am not sure where to find the

objects at so I have been googling like crazy and finding bits and

pieces for my puzzle.

Error message:

[image: http://www.premiertooldesign.com/images/tech/olrule3.gif]

mntn-biker

----------------------------------------mntn-biker's Profile: userid=312
?t=96641
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
this should do it:

Public Sub txtmsgfw(Mail As Outlook.MailItem)

Dim msg As Outlook.MailItem

Dim Recip As Outlook.Recipient

Set msg = Application.CreateItem(olMailItem)

msg.Subject = "Email from customer"

Set Recip = msg.Recipients.Add("myname@domain.com")

Recip.Type = olTo

If msg.Recipients.ResolveAll=False Then

msg.Display

Else

msg.Send

End Sub

Best regards

Michael Bauer

Am Sat, 16 May 2009 20:40:03 +0100 schrieb mntn-biker:


> Michael - Thanks! That got me thru that first part. Now I have been
> messing with adding a recipient and making it send. Here is my code
> (that does not work - see image below):

> Public Sub txtmsgfw(Mail As Outlook.MailItem)
> Dim msg As Outlook.MailItem
> Dim Recip As Outlook.Recipient
> Set msg = Application.CreateItem(olMailItem)
> msg.Subject = "Email from customer"
> Set Recip = .Recipients.Add("myname@domain.com")
> Recip.Type = olTo
> For Each Recip In .Recipients
> If Not Recip.Resolve Then
> msg.Display
> Set msg = Nothing
> End If
> Next
> .Send
> End Sub

> Any ideas?????

> Thanks again for your help! I have been able to read thru the code to
> understand what it is doing however, I am not sure where to find the
> objects at so I have been googling like crazy and finding bits and
> pieces for my puzzle.

> Error message:

> [image: http://www.premiertooldesign.com/images/tech/olrule3.gif]
 
M

mntn-biker

Michael - Thanks a million for your help! I did get an error with the

above code and tweaked it a little to get it to work. Here is what I

wound up with:

Public Sub txtmsgfw(Mail As Outlook.MailItem)

Dim msg As Outlook.MailItem

Dim Recip As Outlook.Recipient

Set msg = Application.CreateItem(olMailItem)

msg.Subject = "Email from customer"

Set Recip = msg.Recipients.Add("myphonenumber@mywirelessphoneco.com")

Recip.Type = olTo

msg.Display

msg.Send

End Sub

Now the only thing I need to do to test it is to wait for my texting to

come back online on my phone......

Thanks again - Mike

mntn-biker

----------------------------------------mntn-biker's Profile: userid=312
?t=96641
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
A Outlook 2010 VBA fails to launch Outlook VBA and Custom Forms 2
D Outlook launch email showing new unread email in reading pane Using Outlook 11
D Launch Outlook showing only selected messages. Using Outlook 1
D Mail in Control Panel Won't Launch Exchange Server Administration 5
D Outlook 2010 won't launch after installin Microsoft office 2010 service pack 1 Using Outlook 1
D How do I get a new mail icon into my quick launch bar? Using Outlook 3
F Launch Marketing Campaign Error BCM (Business Contact Manager) 7
T How to Cancel a queued addon installation on Outlook2003 Launch Outlook VBA and Custom Forms 1
H want to launch outlook with attachemnet for new mail with c# code Outlook VBA and Custom Forms 3
G Creating Macro to scrape emails from calendar invite body Outlook VBA and Custom Forms 4
M Use Macro to change account settings Outlook VBA and Custom Forms 0
J Macro to Reply to Emails w/ Template Outlook VBA and Custom Forms 3
C Outlook - Macro to block senders domain - Macro Fix Outlook VBA and Custom Forms 2
Witzker Outlook 2019 Macro to seach in all contact Folders for marked Email Adress Outlook VBA and Custom Forms 1
S macro error 4605 Outlook VBA and Custom Forms 0
A Macro Mail Alert Using Outlook 4
J Outlook 365 Outlook Macro to Sort emails by column "Received" to view the latest email received Outlook VBA and Custom Forms 0
J Macro to send email as alias Outlook VBA and Custom Forms 0
M Outlook Macro to save as Email with a file name format : Date_Timestamp_Sender initial_Email subject Outlook VBA and Custom Forms 0
Witzker Outlook 2019 Macro GoTo user defined search folder Outlook VBA and Custom Forms 6
D Outlook 2016 Creating an outlook Macro to select and approve Outlook VBA and Custom Forms 0
Witzker Outlook 2019 Macro to send an Email Template from User Defined Contact Form Outlook VBA and Custom Forms 0
Witzker Outlook 2019 Macro to check Cursor & Focus position Outlook VBA and Custom Forms 8
V Macro to mark email with a Category Outlook VBA and Custom Forms 4
M Outlook 2019 Macro not working Outlook VBA and Custom Forms 0
S Outlook 365 Help me create a Macro to make some received emails into tasks? Outlook VBA and Custom Forms 1
Geldner Send / Receive a particular group via macro or single keypress Using Outlook 1
D Auto Remove [EXTERNAL] from subject - Issue with Macro Using Outlook 21
V Macro to count flagged messages? Using Outlook 2
sophievldn Looking for a macro that moves completed items from subfolders to other subfolder Outlook VBA and Custom Forms 7
S Outlook Macro for [Date][Subject] Using Outlook 1
E Outlook - Macro - send list of Tasks which are not finished Outlook VBA and Custom Forms 3
E Macro to block senders domain Outlook VBA and Custom Forms 1
D VBA Macro to Print and Save email to network location Outlook VBA and Custom Forms 1
N VBA Macro To Save Emails Outlook VBA and Custom Forms 1
N Line to move origEmail to subfolder within a reply macro Outlook VBA and Custom Forms 0
Witzker Outlook 2019 Macro to answer a mail with attachments Outlook VBA and Custom Forms 2
A Outlook 2016 Macro to Reply, ReplyAll, or Forward(but with composing new email) Outlook VBA and Custom Forms 0
J Macro to Insert a Calendar Outlook VBA and Custom Forms 8
W Macro to Filter Based on Latest Email Outlook VBA and Custom Forms 6
T Macro to move reply and original message to folder Outlook VBA and Custom Forms 6
D Autosort macro for items in a view Outlook VBA and Custom Forms 2
S HTML to Plain Text Macro - Help Outlook VBA and Custom Forms 1
A Macro to file emails into subfolder based on subject line Outlook VBA and Custom Forms 1
N Help creating a VBA macro with conditional formatting to change the font color of all external emails to red Outlook VBA and Custom Forms 5
S Visual indicator of a certain property or to show a macro toggle Outlook VBA and Custom Forms 2
L Modifying VBA script to delay running macro Outlook VBA and Custom Forms 3
S Macro to extract and modify links from emails Outlook VBA and Custom Forms 3
M Replyall macro with template and auto insert receptens Outlook VBA and Custom Forms 1
L Macro to add Date & Time etc to "drag to save" e-mails Outlook VBA and Custom Forms 17

Similar threads

Top