PDA

View Full Version : Solved: Automate creation of form e-mail each month (with date input)?



Clorox
07-11-2006, 08:04 AM
I've got several e-mail requests I make each month for information from hedge fund managers regarding their portfolios (% invested in a specific region, % cash, etc.).

I request the same information from the same people each month, but each e-mail is unique because I'm writing a single, specific e-mail to a specified person regarding their fund and I am requesting information that relates only to that fund.

However, I do this every month for about a dozen managers, and the only thing that changes in the subject and body are the month to which I am referring (so every time a new month comes around I copy and paste my old e-mail text and subject into a new e-mail addressed to the person and put in the new date info and send it off). I'd like to be able to automate it so that when I run my code it asks me for the date string (doesn't have to be in a date format, it can be 5/31/06 or May 31, 2006, any old text string really) and automatically creates the individual e-mails in my draft folders addressed properly with the specified subject (with the proper date) and proper body text. Is there a way for me to write this in VBA?

Thanks!

MOS MASTER
07-11-2006, 10:14 AM
Hi, :hi:

This should get you started:
Sub SaveEmail()
Dim oItem As Outlook.MailItem

Set oItem = Application.CreateItem(olMailItem)

With oItem
.To = InputBox("Provide E-mail")
.Subject = InputBox("Please provide the subject")
.Body = "Dear " & InputBox("Please provide name") & "," & vbCr & _
"a bunch of text over here" & vbCr & vbCr & _
"the changed date is: " & Format(CDate(InputBox("date")), "mmm, dd yyyy") & _
" a whole lot more text" & vbCr & vbCr & "Good luck to you!"

.Save
End With

Set oItem = Nothing
End Sub


HTH. :whistle:

Clorox
07-12-2006, 06:37 AM
Works perfectly! I've modified it to ask for the date only once and it now inserts the date in the subject as well as the body.

Thanks so much for your help!

Kipp

MOS MASTER
07-12-2006, 01:51 PM
Hi Kipp, :hi:

Glad I could help..:whistle: