VBA code to send emails

thedude1971

Registered User.
Local time
Today, 19:41
Joined
Jun 16, 2011
Messages
10
Hi there,
I am running Access 2010 and I have created a IT helpdesk system. I want it to create an automatic email confirmation when we create helpdesk jobs.

I really need someone to help me with some code that will email the staff using Outlook 2010. I am not a expert on the code side of things.

I require the code assigned to the 'email button' and it will generate a email. Their email address will come from the Access database and in the body of the email there will job status, who it is assigned to etc. The email will then go to the persons email address.

I have attached a old copy of the database, I have saved it in 2000/03 incase people cant open it.

Thanks inadvance.
 
Last edited:
There is a gazillion posts concerning mailing from access on this site. Use the Search menu item at top of this web page and search eg for:
send email

And the above is not to fob you off, but for you to find something suitable and coming back when you have some specific problems :)
 
I have an excel workbook that has dates entered in cells. What I want to do is write someVBA code to automatically send an email 2 weeks ...

 
Last edited:
There is a gazillion posts concerning mailing from access on this site. Use the Search menu item at top of this web page and search eg for:
send email

And the above is not to fob you off, but for you to find something suitable and coming back when you have some specific problems :)

I have had a look through the pages and there lots of info/code there. I found some code and it creates a email for me. However its not taking the data from the database, for example taking the email address Access into outlook.

I have not found any code that does that, if anyone knows?

The code I am using at the moment is:-

Private Sub Command122_Click()
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("the TO email address goes here")
objOutlookRecip.Type = olTo
' Add the CC recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("your FROM email address goes here")
objOutlookRecip.Type = olCC
' Set the Subject, Body, and Importance of the message.
.Subject = "subject name"
.Body = "body of email" & vbCrLf & vbCrLf
.Importance = olImportanceHigh 'High importance
' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
End If
Next
.Send
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
End Sub
 

Users who are viewing this thread

Back
Top Bottom