![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
Firstly, apologies if this turns out not to be a VB question.
I have a situation where a member of my team distributes monthly reports to approx 400 different recipients and at present this is achieved via printing and sending in the mail which takes approx 2 full days. To reduce costs and time taken in this process I would like to automate the process over email. Basically I would like to perform a function similar to mail merge in word whereby I can set a listing of names, email addresses and file names and then run a macro to: -Create a new email to each address in turn. -Include a standard subject -Include a brief passage of text ideally preceeded by recipient name from the listing. -Attach an Excel file relevant to that recipient using the listing (for this I plan to use a common file path each month and maintain the file name). Any suggestions as to if/how this might be achieved would be very welcome. Matt |
Ads |
#2
|
|||
|
|||
![]()
in .net...you'll 1st have to add system.web.mail to your references and
'import system.web.mail. The function I use follows: Public Sub fnSendMail(ByVal psRecipients As String, ByVal psSubject As String, ByVal psBody As String, ByVal psAttachmentLocation As String) Dim Message As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage Message.To = psRecipients Message.From = " Message.Subject = psSubject Message.Body = psBody If psAttachmentLocation.Length 0 Then Try Dim objMailAttachment As New MailAttachment(psAttachmentLocation) Message.Attachments.Add(objMailAttachment) Catch ex As Exception Message.Body &= vbCrLf & "****ERRROR**** " & ex.Message End Try End If Try SmtpMail.SmtpServer = msSMTPIPAddress SmtpMail.Send(Message) Catch ehttp As System.Web.HttpException Call fnWriteToLog("fnSendMail", "Error notifying support personnel = " & ehttp.Message & "..." & ehttp.ErrorCode, "warning") Catch ex As Exception Call fnWriteToLog("fnSendMail", ex.Message, "warning") End Try End Sub |
#3
|
|||
|
|||
![]()
Thanks for the reply.
Unfortunately I am by no means an expert. Is it possible to explain in a little more detail what it is that I need to do? Many thanks " wrote: in .net...you'll 1st have to add system.web.mail to your references and 'import system.web.mail. The function I use follows: Public Sub fnSendMail(ByVal psRecipients As String, ByVal psSubject As String, ByVal psBody As String, ByVal psAttachmentLocation As String) Dim Message As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage Message.To = psRecipients Message.From = " Message.Subject = psSubject Message.Body = psBody If psAttachmentLocation.Length 0 Then Try Dim objMailAttachment As New MailAttachment(psAttachmentLocation) Message.Attachments.Add(objMailAttachment) Catch ex As Exception Message.Body &= vbCrLf & "****ERRROR**** " & ex.Message End Try End If Try SmtpMail.SmtpServer = msSMTPIPAddress SmtpMail.Send(Message) Catch ehttp As System.Web.HttpException Call fnWriteToLog("fnSendMail", "Error notifying support personnel = " & ehttp.Message & "..." & ehttp.ErrorCode, "warning") Catch ex As Exception Call fnWriteToLog("fnSendMail", ex.Message, "warning") End Try End Sub |
#4
|
|||
|
|||
![]()
Matt,
I have found that the macro and procedure for using it described by MVP Doug Robbins in the following link works brilliantly to do excactly what you are asking. I hope you have as much success with it as I have had. Regards, Tim Mc http://word.mvps.org/faqs/mailmerge/...ttachments.htm Xluser@work wrote: Thanks for the reply. Unfortunately I am by no means an expert. Is it possible to explain in a little more detail what it is that I need to do? Many thanks in .net...you'll 1st have to add system.web.mail to your references and 'import system.web.mail. The function I use follows: [quoted text clipped - 29 lines] End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Blank error message when sending attachments | JS | Outlook Express | 3 | January 25th 07 10:47 PM |
Automate mail account creation? | Doug | Outlook - Installation | 2 | February 8th 06 07:03 PM |
Problems sending attachments in Outlook 2003, but works through VNC | Gavin Hanover | Outlook - General Queries | 0 | January 26th 06 06:14 PM |
Outlook deadly slow (mostly static!) when sending attachments | Spamfree! | Outlook - General Queries | 2 | January 24th 06 05:04 PM |
attachments disappear when sending from Act! through Outlook | doug2000 | Outlook - Installation | 0 | January 11th 06 01:05 AM |