Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending an email from access in a specific format

Status
Not open for further replies.

T8JGT

IS-IT--Management
Feb 2, 2005
19
GB
Hi

How can i send an email that has the information from a particular record in the following format:

«ITSQFDocumentName» received from «ProjectServiceDesigner»: ‘«ProjectName»’ - PAR «ProjectPAR»
Go Live - «ProjectLiveDate»

«ProjectSummary»

«ITSQFServRecommendation»«ITSQFQualityGate»
«ITSQFList»

«ITSQFDocumentAddress»

Any ideas
 
create a report with this layout

then, use sendobject to email the report

hope this helps.
 
Below is my SendMail procedure I use. The Message and Body Text is typed into the form and sent like:

myItem.Body = txt.Body

But you can set it to anything you wish like:

strProjectName = Me.txtProjectName
strProjectSummary = Me.txtProjectSummary
strBody = "Project Name:'" & strProjectName & "': '" & strProjectSummary

Add carriage returns, dates and whatever else. You can put returns after each item so the format always looks the same. Also, if it is a template you are after, perhaps MailMerge with word could offer something (using word as your email editor).

Sean.



Private Sub cmdSendMail_Click()
On Error GoTo cmdSendMail_Err

Dim myOlApp As Object
Dim myNameSpace As Object
Dim myFolder As Object
Dim myItem As Object
Dim myAttachments, myRecipient As Object
Dim recipient As String
Dim file_name As String
Dim mySubject As Object
Dim dbs As Object
Dim rst As Object
Dim strSQL As String

Select Case optChapters
Case 1
strSQL = "SelQ_EmailChapter1"

Case 2
strSQL = "SelQ_EmailChapter2"

Case 3
strSQL = "SelQ_EmailChapter3"

Case 4
strSQL = "SelQ_EmailChapter4"

Case 5
strSQL = "SelQ_EmailChapter5"

Case 6
strSQL = "SelQ_EmailChapter6"

Case 7
strSQL = "SelQ_EmailChapter7"

Case 8
strSQL = "SelQ_EmailAll"

Case 9
strSQL = "SelQ_EmailAdministrator"

End Select


Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(strSQL)
rst.MoveFirst
While Not rst.EOF
recipient = rst!Email
Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)
Set myAttachments = myItem.Attachments
Set myRecipient = myItem.Recipients.Add(recipient)
myItem.Subject = Me.txtSubject '"Message Subject String Here"
myItem.Body = Me.txtBody '"Put Message Body Text Here"
myItem.Display
myItem.Send
rst.MoveNext
Wend
Set myRecipient = Nothing
Set myAttachments = Nothing
Set myItem = Nothing
Set myOlApp = Nothing
Set rst = Nothing

cmdSendMail_Exit:
Exit Sub

cmdSendMail_Err:
MsgBox Err.Description
Resume cmdSendMail_Exit

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top