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
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
S Outlook 365 Help me create a Macro to make some received emails into tasks? Outlook VBA and Custom Forms 0
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 10
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
S Macro for Loop through outlook unread emails Outlook VBA and Custom Forms 2
Globalforester ItemAdd Macro - multiple emails Outlook VBA and Custom Forms 3
S Macro to extract email addresses of recipients in current drafted email and put into clipboard Outlook VBA and Custom Forms 2
witzker HowTo start a macro with an Button in OL contact form Outlook VBA and Custom Forms 12
witzker Macro to move @domain.xx of a Spammail to Blacklist in Outlook 2019 Outlook VBA and Custom Forms 7
S Macro for other actions - Outlook 2007 Outlook VBA and Custom Forms 23
C Macro to extract sender name & subject line of incoming emails to single txt file Outlook VBA and Custom Forms 3
L Macro/VBA to Reply All, with the original attachments Outlook VBA and Custom Forms 2
S Macro to move “Re:” & “FWD:” email recieved the shared inbox to a subfolder in outlook Outlook VBA and Custom Forms 0
S Outlook Macro to send auto acknowledge mail only to new mails received to a specific shared inbox Outlook VBA and Custom Forms 0
S Outlook Macro to move reply mail based on the key word in the subjectline Outlook VBA and Custom Forms 0
Eike Move mails via macro triggered by the click of a button? Outlook VBA and Custom Forms 0
S Macro or plug-in to see if specific person was included in this email Outlook VBA and Custom Forms 4
U Macro for reminders,tasks,calendar Outlook VBA and Custom Forms 4
V macro runs slower on startup than after Outlook VBA and Custom Forms 3
N Macro to move all recipients to CC while replying Outlook VBA and Custom Forms 0
A VBA macro for 15 second loop in send and received just for 1 specific mailbox Outlook VBA and Custom Forms 1

Similar threads

Top