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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SMTP mail from Access

Status
Not open for further replies.

tmryan

Programmer
Dec 22, 2000
73
0
0
US
I've been playing with the DoCmd.Send Object in an attempt to send mail on an event. I got it to the point where when the event fires, my local e-mail app is launched and the To, Subject and Text are filled out accordingly. I have to send it manually. My real hope though is to get it to use SMTP mail running on our network - and not local mail, completely invisible to the user.

Can this be done? Does anyone have an example?

Thanks Tim Ryan
PROGRESS Developer
 
This should work for you....

From the Access Help file on DoCmd.SendObject, these are the arguments for DoCmd.SendObject. The second to last one is the import one for you....it determines wheter or not the message pops up or is sent directly...

DoCmd.SendObject [objecttype][, objectname][, outputformat][, to][, cc][, bcc][, subject][, messagetext][, editmessage][, templatefile]


so you should probably have something like (this is one I use):

DoCmd.SendObject , , acFormatRTF, Me![txtEmail].Value, , , Me![txtWO#].Value, Me![Subject].Value, False
Please remember to give helpful posts the stars they deserve! This makes the post more visible to others in need! [thumbsup2]

Robert L. Johnson III, A+, Network+, MCP
Access Developer/Programmer
robert.l.johnson.iii@citigroup.com
 
I have some code which sends an email from excel...
You can maybe change it to ur needs and work it in access...
here goes nothing...

' requires a reference to the Microsoft Outlook 8.0 Object Library
Sub SendAnEmailWithOutlook()
' creates and sends a new e-mail message with Outlook
Dim OLF As Outlook.MAPIFolder, olMailItem As Outlook.MailItem, ToContact As Recipient
Set OLF = GetObject("", "Outlook.Application").GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
Set olMailItem = OLF.Items.Add ' creates a new e-mail message
With olMailItem
.Subject = "Subject for the new e-mail message" ' message subject
Set ToContact = .Recipients.Add("name@domain.com") ' add a recipient
Set ToContact = .Recipients.Add("name@company.com") ' add a recipient
ToContact.Type = olCC ' set latest recipient as CC
Set ToContact = .Recipients.Add("name@org.net") ' add a recipient
ToContact.Type = olBCC ' set latest recipient as BCC
.Body = "This is the message text" & Chr(13) ' the message text with a line break
.Attachments.Add "C:\FolderName\Filename.txt", olByValue, , "Attachment" ' insert attachment
' .Attachments.Add "C:\FolderName\Filename.txt", olByReference, , "Shortcut to Attachment" ' insert shortcut
' .Attachments.Add "C:\FolderName\Filename.txt", olEmbeddedItem, , "Embedded Attachment" ' embedded attachment
' .Attachments.Add "C:\FolderName\Filename.txt", olOLE, , "OLE Attachment" ' OLE attachment
.OriginatorDeliveryReportRequested = True ' delivery confirmation
.ReadReceiptRequested = True ' read confirmation
'.Save ' saves the message for later editing
.Send ' sends the e-mail message (puts it in the Outbox if you are working off-line)
End With
Set ToContact = Nothing
Set olMailItem = Nothing
Set OLF = Nothing
End Sub
 
Rob,

Thanks for the Tip. I'm still having a little trouble with it. I'm still having a little trouble. That argument indicates whether or not to allow editing. It still uses my local mail app (Notes). Do you know how I can force it to use my SMTP mail?

Thanks
Tim Tim Ryan
PROGRESS Developer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top