Go Back   { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Microsoft > MS Office > Access

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-24-2008, 02:51 PM
=?Utf-8?B?UGlldHJv?=
 
Posts: n/a
command to send an e-mail

Hi,

I'm using the below command to send an e-mail,I need the message to open
before sending,so that i may put the To and CC fields.

The code is

Dim mess_body As String
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Dim a As String
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)


DoCmd.SelectObject acQuery, "Tier2 Current Month Report", True
Me.Requery
DoCmd.TransferSpreadsheet acExport, 8, "Tier2 Current Month Report",
"O:\XBOX\XBOX-Tier2\Customer Support\Source\Reports\Current Month Report.xls"


'Application.SetOption "Show Hidden Objects", False
'DoCmd.RunCommand acCmdWindowHide
' DoCmd.SelectObject acForm, "Main page", False
' DoCmd.Maximize

Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)

With MailOutLook
.BodyFormat = olFormatHTML
.to = ""
.CC = ""
.Subject = "Current Month Report"
.HTMLBody = "<P>Dear All<P>" & _
"<P>Kindly find attached Tier2 Current Month
Report</P>" & _
"<P>Best Regards<P>" & _
"Customer Support Tool</P>"



If Left(Me.Mail_Attachment_Path, 1) <> "<" Then
.Attachments.add (Me.Mail_Attachment_Path)

End If
Application.Echo False
DoCmd.SelectObject acTable, "", True
DoCmd.RunCommand acCmdWindowHide
Application.Echo True

'.DeleteAfterSubmit = True 'This would let Outlook send th
note without storing it in your sent bin
.Send
End With
'MsgBox MailOutLook.Body
Exit Sub



email_error:
MsgBox "An error was encountered." & vbCrLf & "The error message
is: " & Err.Description
Resume Error_out
Error_out:
Reply With Quote
  #2 (permalink)  
Old 07-24-2008, 03:06 PM
Arvin Meyer [MVP]
 
Posts: n/a
Re: command to send an e-mail

Add a line immediately before the line:

..Send

so that it looks like:

..Display
..Send

--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


"Pietro" <Pietro@discussions.microsoft.com> wrote in message
news:85D117A5-22E9-4E02-9035-1B4F8E8DD66B@microsoft.com...
> Hi,
>
> I'm using the below command to send an e-mail,I need the message to open
> before sending,so that i may put the To and CC fields.
>
> The code is
>
> Dim mess_body As String
> Dim appOutLook As Outlook.Application
> Dim MailOutLook As Outlook.MailItem
> Dim a As String
> Set appOutLook = CreateObject("Outlook.Application")
> Set MailOutLook = appOutLook.CreateItem(olMailItem)
>
>
> DoCmd.SelectObject acQuery, "Tier2 Current Month Report", True
> Me.Requery
> DoCmd.TransferSpreadsheet acExport, 8, "Tier2 Current Month Report",
> "O:\XBOX\XBOX-Tier2\Customer Support\Source\Reports\Current Month
> Report.xls"
>
>
> 'Application.SetOption "Show Hidden Objects", False
> 'DoCmd.RunCommand acCmdWindowHide
> ' DoCmd.SelectObject acForm, "Main page", False
> ' DoCmd.Maximize
>
> Set appOutLook = CreateObject("Outlook.Application")
> Set MailOutLook = appOutLook.CreateItem(olMailItem)
>
> With MailOutLook
> .BodyFormat = olFormatHTML
> .to = ""
> .CC = ""
> .Subject = "Current Month Report"
> .HTMLBody = "<P>Dear All<P>" & _
> "<P>Kindly find attached Tier2 Current Month
> Report</P>" & _
> "<P>Best Regards<P>" & _
> "Customer Support Tool</P>"
>
>
>
> If Left(Me.Mail_Attachment_Path, 1) <> "<" Then
> .Attachments.add (Me.Mail_Attachment_Path)
>
> End If
> Application.Echo False
> DoCmd.SelectObject acTable, "", True
> DoCmd.RunCommand acCmdWindowHide
> Application.Echo True
>
> '.DeleteAfterSubmit = True 'This would let Outlook send th
> note without storing it in your sent bin
> .Send
> End With
> 'MsgBox MailOutLook.Body
> Exit Sub
>
>
>
> email_error:
> MsgBox "An error was encountered." & vbCrLf & "The error
> message
> is: " & Err.Description
> Resume Error_out
> Error_out:



Reply With Quote
Reply

  { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Microsoft > MS Office > Access


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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 06:15 AM.


Powered by vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
© 1999-2008 mindfrost82.com v11.0


Sponsors:
Adult ADD | Credit Cards | Online Loans | Wallpaper | Debt Consolidation



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109