[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

VB script to delete part of email

Posted on 2004-10-21
3
Medium Priority
?
343 Views
Last Modified: 2010-05-02
I am using the following script to forward all incoming emails that meet a certain rule to my pager.  

Sub StripAndForward(thisMail As Outlook.MailItem)
   
        Const strAddress    As String = "email@domain.com"
                                               
        Const blnAutoSend   As Boolean = True
   
        Dim objFwd As Outlook.MailItem
        Dim objAtt As Outlook.Attachment
       
        For Each objAtt In thisMail.Attachments
            objAtt.Delete                      
        Next objAtt
       
        Set objFwd = thisMail.Forward          
       
        objFwd.Recipients.Add strAddress        
       
        If blnAutoSend = True Then objFwd.Send Else objFwd.Display
                                               
       
        Set objFwd = Nothing
        Set objAtt = Nothing
        Set thisMail = Nothing                  
       
    End Sub


The problem is, there is a character limit on the pager.  I would like to delete all text in the email above a certain keyword (ie. "Problem:") before this email is forwarded.  Is there anything I can add to this script to accomplish this.  Thanks in advance.
0
Comment
Question by:ChWCIT
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 16

Accepted Solution

by:
jimbobmcgee earned 2000 total points
ID: 12370839
Try this:

    'PUT THESE JUST AFTER Sub StripAndForward()
    Const lngPagerMax as Long = 255       'MAX LENGTH OF PAGER MESSAGE
    Const strTextToFind as String = "Problem:"       'TEXT TO USE AS START POINT OF MESSAGE

    'PUT THIS WITH THE OTHER DIMS
    Dim lngPos as Long

    'PUT THIS AFTER objFwd.Recipients...
    lngPos = InStr(1, thisMail.Body, strTextToFind)
    objFwd.Body = Mid(thisMail.Body, lngPos, lngPagerMax)

HTH

J.
0
 

Author Comment

by:ChWCIT
ID: 12371915
Thanks again jimbobmcgee.  This worked great.  Do you also know how to delete the subject line when sending the email.  I am trying to make the email as small as possible.
0
 

Author Comment

by:ChWCIT
ID: 12373033
Never min jimbobmcgee, I figured it out.  
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

656 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