Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Is it possible to personalise email by using detail from To: and Subject:

Posted on 2005-04-20
24
Medium Priority
?
230 Views
Last Modified: 2010-04-08
I wish to send some thank you emails to over 350 people

the names will be in the To: header in "lastname, 1st name" format

and

subject will be in "£5: From xxxxxxxxxxxxxxxx" format

I would like the email to automatically fill in the name and money amount from the header detail

So the body will look something like

Hi "1st name"

You very kindly pledged "detail from subject ie £5"   blah blah blah

Is this possible?

Cheers
G
0
Comment
Question by:GRiTech
  • 13
  • 10
24 Comments
 
LVL 21

Expert Comment

by:JBlond
ID: 13823285
Possibly you can do this with BB script but i'm not very experienced with it.

But afar from that, I recommend to use a program which supports these personalized mass mailings.

Supermailer (http://int.supermailer.de/) is perfect for the scenario you described. It's shareware but if you have to send these mass-mailings often, it's worth to spend some money for it, because it has some features which are very handy for this purpose.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 13830179
Hi GRiTech,

It's easy enough to create the emails using an Outlook macro.  What I'm not clear on is where the lastname, firstname and amount is coming from.  You mention a header but that doesn't solve my confusion.  Do you mean that you have emails from 350 people and you want to generate a reply to each of those messages and the original email contains the header?  If so, then this appears simple.  Otherwise, please clarify and I may be able to help.

Cheers!
0
 
LVL 1

Author Comment

by:GRiTech
ID: 13832041
Blue devil - when you look at a blank outlook mail it has

To...
Cc...
Bcc...
Subject

At the top above where the body goes

The To... area is where the persons email address will be but in this case will be in the format of "lastname,1stname"  this is where the 1st name data will come from

The amount is in the Subject: area and in the format of "£5: From Gary" format. The £5 is seperated from the other text with a colon :


JBlond - Thanks for the link but at present cant seem to get it to do what I want, will keep trying

Cheers
G

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:GRiTech
ID: 13832055
BluedevilFan - Sorry
Yes I have emails from 350 people and I want to generate a reply to each of those messages and the original email contains the header info that I want to pull down into the main body to personalise the reply

Cheers
G
0
 
LVL 76

Expert Comment

by:David Lee
ID: 13832096
Two questions.  What version of Outlook are you using?  Are those 350 messages all in a separate folder or is there a simple way of picking them out so we know which messages to reply to and don't reply to other messages?  The code for doing this is very straightforward assuming that all 350 of those messages are formatted as you described.  By that I mean that the sender name is always "Lastname, Firstname" and the Subject line always contains £x where x is the amount.  If so, if your version of Outlook doesn't present any problems, and if we can identify just those messages that you want to respond to, then I can write a macro and have it posted by the end of today.  
0
 
LVL 1

Author Comment

by:GRiTech
ID: 13833362
BlueDevilFan - Outlook 2002, the messages are all in a seperate folder

Just remembered some might not have a money amount but might have "other:" ranther than £x

Hmmm dont worry about that I'll filter those ones out
0
 
LVL 76

Expert Comment

by:David Lee
ID: 13839527
GRiTech,

Here's the macro.  To use it you'll need to do the following:
1.  Start Outlook
2.  Click Tools->Macro->Visual Basic Editor
3.  If not already expanded, expand Modules and click on Module1
4.  Copy the code below and paste it into the right-hand pane of the VB Editor window
5.  Edit the code making the changes per the comments I embeded in the code
6.  Click the diskette icon on the toolbar to save the changes
7.  Close the VB Editor
8.  Click Tools->Macro->Security
9.  Set the Security Level to Medium
10.  Test the macro on a message sent to yourself
11.  When the macro creates the response you're going to get a pop up dialog-box saying that an application is accessing your mailbox and asking for permission to allow it to.  I recommend setting the access time to 10 minutes and clicking yes.  
12.  When the macro sends the response you're going to get another pop up dialog box, this time asking for permission to send.  Once again you'll need to say yes.  Microsoft added these security measures to combat all the viruses and worms that have been written to use Outlook as a means of transmission.  There's no simple means of turning them off.  If you'd instead prefer to send the messages yourself, giving you a chance to review each one and make any changes, then change olResponse.Send to olResponse.Display.  This will cause each message to appear onscreen.  

The macro is predicated on then name appearing lastname first, and on the subject line being formatted with a £ followed by the amount pledged and a colon.  If the subject line isn't layed out like that on a given message, then the macro is going to mess up.

Sub SendPledgeMessage()
    Dim olFolder As MAPIFolder, _
        olMessage As MailItem, _
        olResponse As MailItem, _
        olTemp As Object, _
        arrName As Variant, _
        intStart As Integer, _
        intEnd As Integer, _
        strDonation As String
    'Change the folder path on the next line to the path of your folder
    Set olFolder = OpenMAPIFolder("\FolderOrMailboxName\Subfolder")
    For Each olMessage In olFolder.Items
        arrName = Split(olMessage.SenderName, ",")
        intStart = InStr(1, olMessage.Subject, "£")
        intEnd = InStr(1, olMessage, ":")
        strDonation = Mid(olMessage.Subject, intStart + 1, intEnd - (intStart + 1))
        Set olResponse = Application.CreateItem(olMailItem)
        Set olTemp = olMessage.Reply
        olResponse.Recipients.Add olMessage.Recipients.Item(1).Address
        Set olTemp = Nothing
        'Change the subject line as desired
        olResponse.Subject = "Your Pledge"
        'Change the message body as desired
        olResponse.Body = "Hi " & arrName(1) & vbCrLf & vbCrLf & _
            "You very kindly pledged £" & strDonation
        olResponse.Send
    Next
    Set olResponse = Nothing
    Set olMessage = Nothing
    Set olFolder = Nothing
End Sub
0
 
LVL 1

Author Comment

by:GRiTech
ID: 13841363
BlueDevil - Thanks for that I will try it out, One thing I thought of or rather told you incorrectly (Due to a dehydrated brain having run London Marathon)  The name information is in the From: section and not the To:.. section as I stated.

Other than that the last name apears first seperated from 1st name with a commer (,) and £ sign appears 1st on subject line.

Thanks for your help
Gary
0
 
LVL 76

Expert Comment

by:David Lee
ID: 13841964
Hi, Gary.

I run too, although not marathons, so I completely understand about the dehydrated brain.  I didn't even notice the slip on To versus From and wrote the code to get the name from the From line.  I did write the code to expect the pound sign first on the Subject line.  We should be in good shape.  

Let me know if you run into problems, or if there's anything else I can do.
0
 
LVL 1

Author Comment

by:GRiTech
ID: 13842419
Thats brill I have some additional text that goes below the "You very kindly pledged £" & strDonation" bit how do i put that in?

Format needs to be

"You very kindly pledged £" & strDonation"

"I can't thank you all enough for your support which made such a big difference on the day, we ...........blah blah etc etc"

0
 
LVL 76

Expert Comment

by:David Lee
ID: 13842842
You can change the message body to anything you want by editing this bit of code:

olResponse.Body = "Hi " & arrName(1) & vbCrLf & vbCrLf & _
            "You very kindly pledged £" & strDonation

Litteral text needs to be enclosed in quotes and each litteral or variable is appended by adding a & and the litteral/variable.  vbCrLf is a carriage-return line-feed pair.  So, to add the text from your post you'd use something like this:

olResponse.Body = "Hi " & arrName(1) & vbCrLf & vbCrLf & _
            "You very kindly pledged £" & strDonation & vbCrLf & vbCrLf & _
            "I can't thank you enough for your support  which made such a big difference on the day, we ..."

This would produce a body that reads:

Hi Gary

You very kindly pledged £50

I can't thank you enough .....
0
 
LVL 1

Author Comment

by:GRiTech
ID: 13842977
This is what Ive tried so far but keep getting "Compile error sub or function not defined"  Sub SendPledgeMessage() gets highlighted in yellow and OpenMAPIFolder in blue.

Any idea's

Sub SendPledgeMessage()
    Dim olFolder As MAPIFolder, _
        olMessage As MailItem, _
        olResponse As MailItem, _
        olTemp As Object, _
        arrName As Variant, _
        intStart As Integer, _
        intEnd As Integer, _
        strDonation As String
    'Change the folder path on the next line to the path of your folder
    Set olFolder = OpenMAPIFolder("\Rudley,Gary\Test")
    For Each olMessage In olFolder.Items
        arrName = Split(olMessage.SenderName, ",")
        intStart = InStr(1, olMessage.Subject, "£")
        intEnd = InStr(1, olMessage, ":")
        strDonation = Mid(olMessage.Subject, intStart + 1, intEnd - (intStart + 1))
        Set olResponse = Application.CreateItem(olMailItem)
        Set olTemp = olMessage.Reply
        olResponse.Recipients.Add olMessage.Recipients.Item(1).Address
        Set olTemp = Nothing
        'Change the subject line as desired
        olResponse.Subject = "Gary's London Marathon Update"
        'Change the message body as desired
        olResponse.Body = "Hi " & arrName(1) & vbCrLf & vbCrLf & _
            "You very kindly pledged to sponsor me for a total of £" & strDonation
        olResponse.Send
    Next
    Set olResponse = Nothing
    Set olMessage = Nothing
    Set olFolder = Nothing
End Sub
0
 
LVL 76

Expert Comment

by:David Lee
ID: 13844724
Doh, I forgot to paste in the OpenMAPIFolder() function.  Sorry about that.  Here it is.  Copy and paste this in just below the other code.

'Credit where credit is due.
'The code below is not mine.  I found it somewhere on the internet but do
'not remember where or who the author is.  The original author(s) deserves all
'the credit for these functions.
Function OpenMAPIFolder(szPath)
    Dim app, ns, flr, szDir, i
    Set flr = Nothing
    Set app = CreateObject("Outlook.Application")
    If Left(szPath, Len("\")) = "\" Then
        szPath = Mid(szPath, Len("\") + 1)
    Else
        Set flr = app.ActiveExplorer.CurrentFolder
    End If
    While szPath <> ""
        i = InStr(szPath, "\")
        If i Then
            szDir = Left(szPath, i - 1)
            szPath = Mid(szPath, i + Len("\"))
        Else
            szDir = szPath
            szPath = ""
        End If
        If IsNothing(flr) Then
            Set ns = app.GetNamespace("MAPI")
            Set flr = ns.Folders(szDir)
        Else
            Set flr = flr.Folders(szDir)
        End If
    Wend
    Set OpenMAPIFolder = flr
End Function

Function IsNothing(Obj)
  If TypeName(Obj) = "Nothing" Then
    IsNothing = True
  Else
    IsNothing = False
  End If
End Function
0
 
LVL 1

Author Comment

by:GRiTech
ID: 13857443
Sorry about this but I've got this now,  still getting an error "The operation failed. An object could not be found"  this line is highlighted yellow   Set flr = ns.Folders(szDir)

Sub SendPledgeMessage()
    Dim olFolder As MAPIFolder, _
        olMessage As MailItem, _
        olResponse As MailItem, _
        olTemp As Object, _
        arrName As Variant, _
        intStart As Integer, _
        intEnd As Integer, _
        strDonation As String
    'Change the folder path on the next line to the path of your folder
    Set olFolder = OpenMAPIFolder("\Rudley,Gary\Mail")
    For Each olMessage In olFolder.Items
        arrName = Split(olMessage.SenderName, ",")
        intStart = InStr(1, olMessage.Subject, "£")
        intEnd = InStr(1, olMessage, ":")
        strDonation = Mid(olMessage.Subject, intStart + 1, intEnd - (intStart + 1))
        Set olResponse = Application.CreateItem(olMailItem)
        Set olTemp = olMessage.Reply
        olResponse.Recipients.Add olMessage.Recipients.Item(1).Address
        Set olTemp = Nothing
        'Change the subject line as desired
        olResponse.Subject = "Gary's London Marathon Update"
        'Change the message body as desired
        olResponse.Body = "Hi " & arrName(1) & vbCrLf & vbCrLf & _
            "You very kindly pledged to sponsor me for a total of £" & strDonation
        olResponse.Send
    Next
    Set olResponse = Nothing
    Set olMessage = Nothing
    Set olFolder = Nothing
End Sub
Function OpenMAPIFolder(szPath)
    Dim app, ns, flr, szDir, i
    Set flr = Nothing
    Set app = CreateObject("Outlook.Application")
    If Left(szPath, Len("\")) = "\" Then
        szPath = Mid(szPath, Len("\") + 1)
    Else
        Set flr = app.ActiveExplorer.CurrentFolder
    End If
    While szPath <> ""
        i = InStr(szPath, "\")
        If i Then
            szDir = Left(szPath, i - 1)
            szPath = Mid(szPath, i + Len("\"))
        Else
            szDir = szPath
            szPath = ""
        End If
        If IsNothing(flr) Then
            Set ns = app.GetNamespace("MAPI")
            Set flr = ns.Folders(szDir)
        Else
            Set flr = flr.Folders(szDir)
        End If
    Wend
    Set OpenMAPIFolder = flr
End Function

Function IsNothing(Obj)
  If TypeName(Obj) = "Nothing" Then
    IsNothing = True
  Else
    IsNothing = False
  End If
End Function


Regards
G

0
 
LVL 76

Expert Comment

by:David Lee
ID: 13862694
Gary,

It's almost certainly because the folder path is incorrect.  Copy this macro and paste it in with the other code.  Now, go hilight a message in the folder whose path you want and run the macro.  It'll pop up a dialog-box showing the path to the folder.  The folder path will begin with \\.  Strip off one of the backslashes and you'll have the path you want.

Sub DisplayFolderPath()
    Dim objSelectedItems As Outlook.Selection, _
        objItem As Outlook.MailItem
    Set objSelectedItems = Application.ActiveExplorer.Selection
    For Each objItem In objSelectedItems
        MsgBox objItem.Parent.FolderPath
    Next
End Sub
0
 
LVL 1

Author Comment

by:GRiTech
ID: 13865315
WooooHoooo your a star ... got the test mail to work.  Just trying to sort out the text body ...got lots of red showing at present.

How do you make text in the body bold? and change the font size?

I have increased the points in recognition of your help

Thanks
G
0
 
LVL 76

Expert Comment

by:David Lee
ID: 13865348
What format, HTML or RTF?
0
 
LVL 1

Author Comment

by:GRiTech
ID: 13865492
Got the text body sorted now...no more red ;o)

How do i make text in the body bold? and change the font size?

Cheers
G
0
 
LVL 1

Author Comment

by:GRiTech
ID: 13865521
Sorry diddnt see your question

HTML is the answer
0
 
LVL 1

Author Comment

by:GRiTech
ID: 13865887
just tried a test on a couple of real mails and everything fills in correctly, except the email is sent to me and not the origional sender.

Which bit do I need to change to alter that?

Cheers
Gary
0
 
LVL 1

Author Comment

by:GRiTech
ID: 13867684
have managed to resolve the email being sent to me when macro is run by changing the below line to SenderName

CHANGED TO - olResponse.Recipients.Add olMessage.SenderName
OLD -        'olResponse.Recipients.Add olMessage.Recipients.Item(1).Address

that seems to work OK and picks up the persons email address
0
 
LVL 76

Accepted Solution

by:
David Lee earned 1200 total points
ID: 13872313
I don't understand why the responses were going to you instead of to the sender.  The approach I used is the correct approach for Outlook 2002.  The approach you used should only work if the sender's name is in a contact list (e.g. Contacts or GAL) since it doesn't contain an email address.  But, who can argue with success?  If you want to send an HTML response, then replace all references to olResponse.Body with olResponse.HTMLBody.  An HTML message takes standard HTML markeup, so to bold something place <b></b> tags around the item.  To change the font size, enclose the item in <span></span> tags like this: <span style="font-size: 16px"></span>  This would change the font of the text between the span tags to 16 point.  You'll also need to replace the vbCrLf constants in the original text with <br> tags.  Using the original message body I posted as an example, we'd change this

 olResponse.Body = "Hi " & arrName(1) & vbCrLf & vbCrLf & _
            "You very kindly pledged to sponsor me for a total of £" & strDonation

to this

 olResponse.HTMLBody = "<b>Hi " & arrName(1) & "</b><br><br>" & _
            "You very kindly pledged to sponsor me for a total of <span style='font-size: 16px'>£" & strDonation & "</span>"

Of course I don't know if that's where you want the bold and font size change placed.
0
 
LVL 1

Author Comment

by:GRiTech
ID: 13874566
Thats great all 380 odd mails sent, bit of a pain having to say yes you want to send each one but ...nothings ever perfect.

and I learnt a bit along the way.

Thanks for all your help.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 13880856
Cool.  Glad I could be of assistance.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

This article lists the top 5 trialware OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their Exchange server is no longer available or other critical issues with Exchange server or impo…
With so many activities to perform, Exchange administrators are always busy in organizations. If everything, including Exchange Servers, Outlook clients, and Office 365 accounts work without any issues, they can sit and relax. But unfortunately, it…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

571 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