Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / New Users / April 2008

Tip: Looking for answers? Try searching our database.

send mail

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
hyperionaxa - 07 Apr 2008 16:42 GMT
Hi, I am tring to create something on access 2003 to send external mail to
the suppliers and I am using the following code:

Private Sub CommandButton1_Click()
'Sub Mail_Selection_Range_Outlook_Body()
' Don't forget to copy the function RangetoHTML in the module.
' Working in Office 2000-2007
   Dim rng As Range
   Dim OutApp As Object
   Dim OutMail As Object
   Dim strbody As String

   Set rng = Nothing
   On Error Resume Next
   'Only the visible cells in the selection
   'Set rng = Selection.SpecialCells(xlCellTypeVisible)
   'You can also use a range if you want
   Set rng = Sheets("SHEETNAME").Range("a1:b18").SpecialCells
(xlCellTypeVisible)
   On Error GoTo 0

   If rng Is Nothing Then
       MsgBox "The selection is not a range or the sheet is protected" & _
              vbNewLine & "please correct and try again.", vbOKOnly
       Exit Sub
   End If

   With Application
       .EnableEvents = False
       .ScreenUpdating = False
   End With

   Set OutApp = CreateObject("Outlook.Application")
   OutApp.Session.Logon
   Set OutMail = OutApp.CreateItem(0)

   On Error Resume Next
   With OutMail
       .To = "JB@XYZ.co.uk"
       '.CC = ""
       '.BCC = ""
       .Subject = "Report"
       strbody = "xyz" & "<br>" & _
                  "" & "<br>" & _
                  "Thanks" & "<br><br><br>"
       .HTMLBody = strbody & RangetoHTML(rng)
       .Send   'or use .Display
   End With
   On Error GoTo 0

   With Application
       .EnableEvents = True
       .ScreenUpdating = True
   End With

   Set OutMail = Nothing
   Set OutApp = Nothing
End Sub

But, the issue is that, users would like to input/change the email address
for the emails to be sent. CAN SOMEONE PLEASE HELP ME WITH THIS.

Thanks in advance.
Evi - 07 Apr 2008 23:39 GMT
Have a textbox in your form with button and replace the JB@XYZ.co.uk with a
variable

add a declaration to your 'Dim' section

Dim MyEmailAddy as Hyperlink

MyEmailAddy = Me.Text1 (or whatever you decide to call the text box)

then change the email line to

        .To = MyEmailAddy

Evi
> Hi, I am tring to create something on access 2003 to send external mail to
> the suppliers and I am using the following code:
[quoted text clipped - 62 lines]
> --
> Message posted via http://www.accessmonster.com
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.