A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

How to automate sending email with different attachments



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old January 11th 06, 02:12 PM posted to microsoft.public.outlook.program_vba
Xluser@work
external usenet poster
 
Posts: 4
Default How to automate sending email with different attachments

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  
Old January 11th 06, 06:39 PM posted to microsoft.public.outlook.program_vba
[email protected]
external usenet poster
 
Posts: 1
Default How to automate sending email with different attachments

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  
Old January 20th 06, 10:19 AM posted to microsoft.public.outlook.program_vba
Xluser@work
external usenet poster
 
Posts: 4
Default How to automate sending email with different attachments

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  
Old January 25th 06, 05:33 AM posted to microsoft.public.outlook.program_vba
Tim Mc
external usenet poster
 
Posts: 1
Default How to automate sending email with different attachments

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
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


All times are GMT +1. The time now is 08:44 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.