Solved

need line to add to script in outlook

Posted on 2010-11-26
13
248 Views
Last Modified: 2012-05-10
Need line of script to forward email to bigbill99.3fc@m.evernote.com for outlook 2010
0
Comment
Question by:Bigbill93638
  • 5
  • 5
  • 3
13 Comments
 
LVL 13

Expert Comment

by:gbanik
ID: 34222681
Here's your code...
Option Explicit
Private Const sForwardAddr As String = "bigbill99.3fc@m.evernote.com"

Public Sub ForwardAllSelectedMails()
   On Error Resume Next
    Dim objItem As Outlook.MailItem

    If Application.ActiveExplorer.Selection.Count = 0 Then
        Exit Sub
    End If

    For Each objItem In Application.ActiveExplorer.Selection
        If objItem.Class = olMail Then
            Set objItem = objItem.Forward
            objItem.To = sForwardAddr
            objItem.Send
        End If
    Next
    
End Sub

Open in new window

0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 34223621
Adapting from the earlier rule then how about:

Note if the subject is to be unchanged on the forward then delete the first two lines and enable the last two

Chris
Sub Q26638986(Item As MailItem)
dim mai as object

    Item.Subject = Item.Subject & " @quotes #quotes"
    Item.Save

    Set mai = objItem.Forward
    mai.To = bigbill99.3fc@m.evernote.com
    mai.Send

'    Item.Subject = Item.Subject & " @quotes #quotes"
'    Item.Save

 
End Sub

Open in new window

0
 

Author Comment

by:Bigbill93638
ID: 34223655
chris it gives me an error at the . in the email address and says compile error expected end of sub
0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
LVL 13

Expert Comment

by:gbanik
ID: 34223817
@Bigbill93638, did the code piece I suggested work for you?
0
 

Author Comment

by:Bigbill93638
ID: 34224176
no, the first part works, then it doesn't forward. as below

Sub Q26638986(Item As MailItem)
    Item.Subject = Item.Subject & " @quotes #quotes"
    Item.Save
Option Explicit
Private Const sForwardAddr As String = "bigbill99.3fc@m.evernote.com"

Public Sub ForwardAllSelectedMails()
   On Error Resume Next
    Dim objItem As Outlook.MailItem

    If Application.ActiveExplorer.Selection.Count = 0 Then
        Exit Sub
    End If

    For Each objItem In Application.ActiveExplorer.Selection
        If objItem.Class = olMail Then
            Set objItem = objItem.Forward
            objItem.To = sForwardAddr
            objItem.Send
        End If
    Next
   
End Sub
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 34224371
OOps missed a bit


Can't test currently as I haven't installed office in the Windows partition and cant enable macros in the Mac version .... still, note to self must request attention on my Q!.

Chris
ub Q26638986(Item As MailItem)
dim mai as object

    Item.Subject = Item.Subject & " @quotes #quotes"
    Item.Save

    Set mai = objItem.Forward
    mai.To = "bigbill99.3fc@m.evernote.com"
    mai.Send

'    Item.Subject = Item.Subject & " @quotes #quotes"
'    Item.Save

 
End Sub

Open in new window

0
 
LVL 13

Expert Comment

by:gbanik
ID: 34225506
@Bigbill93638, thats not the code I posted. Can you please check my code (posted again below)? I have rechecked and it seems this may be what u want.
Option Explicit
Private Const sForwardAddr As String = "bigbill99.3fc@m.evernote.com"

Public Sub ForwardAllSelectedMails()
   On Error Resume Next
    Dim objItem As Outlook.MailItem

    If Application.ActiveExplorer.Selection.Count = 0 Then
        Exit Sub
    End If

    For Each objItem In Application.ActiveExplorer.Selection
        If objItem.Class = olMail Then
            Set objItem = objItem.Forward
            objItem.To = sForwardAddr
            objItem.Send
        End If
    Next
    
End Sub

Open in new window

0
 

Author Comment

by:Bigbill93638
ID: 34225952
qbanik, I need to add what you did to what I have in order for it to work, the first part codes it for evernote the second part (what you are doing) sends it. Can you make that work?
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 34225965
Nothing from my post?

Chris
Sub Q26638986(Item As MailItem)
dim mai as object

    Item.Subject = Item.Subject & " @quotes #quotes"
    Item.Save

    Set mai = objItem.Forward
    mai.To = "bigbill99.3fc@m.evernote.com"
    mai.Send

'    Item.Subject = Item.Subject & " @quotes #quotes"
'    Item.Save

 
End Sub

Open in new window

0
 

Author Comment

by:Bigbill93638
ID: 34226014
Chris, no it doesn't give me the error but it doesn't forward either.
0
 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 500 total points
ID: 34226215
Ah

HAd to make another mod to work with the old code ... as said before lack of working outlook install is  pain!

Chris
ub Q26638986(Item As MailItem)
dim mai as object

    Item.Subject = Item.Subject & " @quotes #quotes"
    Item.Save

    Set mai = Item.Forward
    mai.To = "bigbill99.3fc@m.evernote.com"
    mai.Send

'    Item.Subject = Item.Subject & " @quotes #quotes"
'    Item.Save

 
End Sub

Open in new window

0
 

Author Comment

by:Bigbill93638
ID: 34226281
That worked, thanks!
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 34226313
Sorry about the error, the problem with cut and paste from an object file copy.

Chris
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Resolve Outlook connectivity issues after moving mailbox to new Exchange 2016 server
This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question