Modules & VBA :: Can't Make New Line When Pushing Outlook Email
Mar 20, 2014
i'm trying to send an Outlook e-mail from Access. Everything works fine except for one thing:
When generating the HTMLBody I use vbNewLine for starting a new line in the string that works fine as long as being in Access. However after displaying it in Outlook there are no any new lines in the mail text; the complete text is one mass.
I'm trying to write a line of VBA code (in an existing Access 2010 DB) that changes the Subject Line of all selected emails in my Outlook Inbox to today's date.
When I build the statement I want to email and view it in a MsgBox the lines space correctly with the code vbCrLf.However when I send that text out as the body of the email, the spacing is no longer there and its just one big pile of nonsenses. In the MsgBox I see it correctly as:
Tool Box 5 Drawer 3 Tag Number 4 Drawer 2 Tag Number 6 Tool Box 7 Drawer 8 Tag Number 2
But in the Email it comes out as: Tool Box 5 Drawer 3 Tag Number 4 Drawer 2 Tag Number 6 Tool Box 7 Drawer 8 Tag Number 2
I'm trying to have a command button send info on the form straight to Outlook as a meeting. So far, the code below works apart from the address bit. I need the code to automatically add the same 2 email addresses as recepients everytime.
Error message highlights the red line below with the following message:
Runtime error '438' Object doesn't support this property or method
I'm new to VBA, so don't understand what is wrong here. The reference is set, I've tried different permutations of the "To:" & "Recipients.Add" for the email address with no joy.
Code: Private Sub cmdSend_Click() Dim outApp As Object Set outApp = CreateObject("Outlook.application") Set outmail = outApp.CreateItem(olappointmentitem)
I am trying to capture a newly arrived mail in outlook with respective subject line. The below code works for me on 2010 outlook but when new mail arrive in outlook 2013 ,Mrthod Items_ItemAdd do not get called.
Code:
Option Explicit Private WithEvents Items As Outlook.Items Private Sub Application_Startup() Dim olApp As Outlook.Application Dim objNS As Outlook.NameSpace Set olApp = Outlook.Application Set objNS = olApp.GetNamespace("MAPI") ' (1) default Inbox
I'm trying to make it so when a subform is updated, it will email the contents of that subform to me. I've got it all working, except for the content of the email part.
Code: Sub SendRepReassignment() Dim oOutlook As Outlook.Application Dim oEmailItem As MailItem Dim objOutlookAttach As Outlook.Attachment On Error Resume Next Err.Clear
I am making a new database. And I want to confirm that I can do all the following in Access 2007 and how is best to do it.
1) A form where I can define:a unique Email Number starting at 1. a directory eg "C:UsersPaulDesktop101 - Brick House" an email address. a Recipient Name a Category for the email. Choosing either "Working" or "Complete". This would be part of the email subject.
2) a button which onclick lists all the files in the defined directory to a box on the form.
3) a button which onclick exports a report containing the list of files to PDF. Then attaches a zip of these files and the PDF report to an email in Outlook for revision before sending.
4)In Outlook the subject would be:
"The Directory Name" - "The Category" - "The Email Number" "101 - Brick House - Working - Email 1"
5)In Outlook the body would simply be the subject of the email followed by the filenames of the 2 attached files, ie the PDF report and the zip.
I am a College Instructor and I would like to make a Database that will regularly email me a list of Students who are approaching the mid-point of their Program.Is it possible to program Access to email a list with Student Names, Registration Numbers, etc, etc. by a given date?
As of right now I have a Database with all of the students' pertinent information but I have to manually comb through the Database each week to see which students will require a Mid-Term interview that week.
I have been trying to get this to work but without success.
My original source was [URL] ....
The code looks good apart from the fact that the Inspector was not Dimensioned. Anyway, here is my code which fails as the error message is that objSel is not set.
Code: Dim MyOutlook As Outlook.Application Dim MyMail As Outlook.MailItem Set MyOutlook = New Outlook.Application Set MyMail = MyOutlook.CreateItemFromTemplate(DLookup("TemplateFolder", "Company Details") & "eMail Template bm4.oft")
I'd like a command button to open Outlook and create a new email message with the To and Subject fields already populated with what I want, is there anyway to do this?
What i would like to do is replace the DoCmd.OutputTo line with a DoCmd.SentTo line to email the reports to the appropriate faculty instead of just saving them in the folder.
I used this line but it did not work: DoCmd.SendObject (acSendReport, , acFormatPDF, "vtblfaculty.email&'@xxx.edu'","me@xxx.edu",,"test ","this is a test",-1,,)I have been working on this forever!
Public Sub something3() Dim db As Database Dim rs As DAO.Recordset Set db = CurrentDb Set rs = db.OpenRecordset("SELECT DISTINCT tblsection.Faculty, left(vtblfaculty.firstname,1)&vtblfaculty.lastname AS fn, vtblfaculty.email FROM vtblfaculty INNER JOIN tblsection ON tblsection.faculty=vtblfaculty.faculty WHERE term=" & Forms!frmimport!cbxTerm)
I would like to create a button that when pressed opens up an outlook email. The email address will be populated by one email address every time. I don't want it to automatically send as the body will need to be filled out by the user. It would be useful if the date and time it was sent could be recorded in the form somewhere too (would this be in a text box?).
I found a code that will go trough an emailbox and export all emails to a table in access. This part is working OK (except the received date). I also wante to show in the table if the email contains an attachment, but that part is not working at all. The project actually is meant to store the emails on a shared drive and attachments and have the emails in Access so I can see them all and recall the one needed.
Code: Private Sub Command14_Click() Dim TempRst As DAO.Recordset Dim rst As DAO.Recordset
I have vba code set up to automate a query output to email with outlook. I am having issues with the "TO" field. I have tried different types of code, such as the following:
Both of these work, but the issue I am having is the "TO" field in the outlook message looks like this: admin@blahblah#mailto:admin@blahblah#
Why my code is adding the email address twice, I need to get rid of the #mailto:admin@blahblah# but I do not know how or why it keeps adding that end part.
I am currently in the process of creating a form that will allow you to enter details for an email sent, select a number of documents from a list box and then open the mail message pre-written with attachments. The attachments reside in a list box currently, and I am attempting to use a "For Each" with item selected.column(3) as the file path, as column(3) contains the filepath from the table.
Currently my code is:
Private Sub OutlookBut_Click() Dim olApp As Object Dim objMail As Object Dim varItm As Variant On Error Resume Next Set olApp = GetObject(, "Outlook.Application")
[Code] ....
When this code runs, outlook will open as a process when it is closed, but then freeze and not allow me to see it or access it in anyway. If Outlook is opened Microsoft office usually gets angry at me and decides to throw error messages at me.
I have code that automatically send emails out from an Access Customer Contacts Database. I am using Access and Outlook 2007 but the code needs to work with later versions of Access and Outlook.
I have very poor knowledge of coding and usually manage to cobble something together from looking at other code on the net but don't understand most of it.
I have the following code which works perfectly except I want to be able to embed an image in the email body (not have the image as an attachment but actually show it in the body of the email).
Most of the code I have found around this topic is too complex for me to understand and utilise within the context of the code I have.
Ideally I want to take the image from an attachment field in a table returned by the "tblMailingList_Query".
Code: Private Sub Command10_Click() Dim MyDB As Database Dim MyRS As Recordset Dim objOutlook As Outlook.Application Dim objOutlookMsg As Outlook.MailItem
I have access db sending report with outlook every Monday.
But the problem is if outlook is open when I start the db, email goes in to outgoing folder and msg box of outlook opens saying " outlook will close after countdown if I do not hit the "DO NOT EXIT" button or "EXIT AND SEND LATER" button.
If I hit "EXIT AND SEND LATER" button, it sends next time I open the outlook.
I wrote VBA code to pull email messages from Outlook in order to create an alert if a message with a specific subject line is not received. I have the system coded to send the alert if the message isn't found before the system encounters a message with a SentOn date/time more than two hours old.
The code has worked great for over a year, but now my company is migrating to Win8 and I'm having issues with the code. The machine that normally runs the process uses XP and Access 2007. The code also works on another machine running Windows 7 and Access 2010.
The issue I'm having in Win8, with Access 2010, is that the code isn't pulling the most recent message first. Instead, it is selecting a message from about two weeks ago, and then cycling through the other messages from that point. I know there are ways I can code around this, but I don't want to if I don't have to.
Is there a setting that I'm missing? I've included the basic code to pull the email messages below:
Code: DoCmd.SetWarnings False Dim ol As Outlook.Application Dim ns As Namespace Dim Inbox As MAPIFolder Dim Item As Object Dim strSubject, strSentDate As String
Is there a way of doing the above? I have several distribution lists (some >100 recipients) defined in Outlook, and would like to use the Docmd. Send Object command to send messages to one or several of them. I cannot find a way of defining a distribution list as any of the To, Cc or Bcc parameters.
I have the following string of text that I currently push out to the body of an Outlook email (using the DoCmd.SendObject function with an Access report):
Which is great and works fine! It appears in the email like so:
Original.PNG
Now, it has been requested that the data to be left justified to the widest line... so, in this scenario, it would look like this:
Edit.PNG
I've searched for ways this might be accomplished so it's always left justified to the widest line, but haven't come across any definitive solutions yet.
I have been able to successfully set up code to be able to add appointments to microsoft outlook based on data within a few forms that I have. My question is this however, how do I get access to make that appointment to a specific calendar on outlook. This calendar is a shared calendar. Currently, access is just adding the appointments to "My Calendar" and I could like it to place the appointment on "HVCalendar". a version of the code I found online is listed below:
Private Sub btnaddappttooutlook_Click() 'On Error GoTo ErrHandle
Dim olNS As Object Dim olApptFldr As Object
' Save the Current Record If Me.Dirty Then Me.Dirty = False