Help Help With Email Function

Dec 6, 2006

i'm writing a function to send an email with the option of attachements
This is the code i'm using, it works fine but i need to be able to sne mulitple attachments. What would be the best way of doing this?

Thanks

code:
Public Function SendEmail(strTo As String, strSubject As String, strBody As String, Optional strCC As String, Optional strAttached As String)
Dim olkapps As Outlook.Application
Dim olknamespaces As Outlook.Namespace
Dim objmailitems As Outlook.MailItem
Set olkapps = New Outlook.Application
Set olknamespaces = GetNamespace("MAPI")
Set objmailitems = olkapps.CreateItem(olMailItem)
With objmailitems
.To = strTo
If IsNull(strCC) = False Then
.CC = strCC
End If
.Subject = strSubject
.Body = strBody
If IsNull(strAttached) = False Then
.Attachments.Add strAttached
End If
.Send
End With
Set objmailitems = Nothing
Set olknamespaces = Nothing
Set olkapps = Nothing
End Function

View Replies


ADVERTISEMENT

How Do I Trigger A Function In Access By Email?

Apr 18, 2006

Does anyone know of a way to trigger a function in Access when a specific email is received in Outlook?

Thank you for reading this question and for those that reply, thank you for your time and knowledge.

View 1 Replies View Related

Access Email Function For Data Collection?

Aug 14, 2012

I have set up an access database and want to collect data using the e-mail feature. I can use the feature but the form it sends to fill out is very basic and not that user friendly. I want to put in directions to the form, is there a way to change the style of the form?

View 1 Replies View Related

Modules & VBA :: Replace Function In Access 2007 For HTML Email In Outlook 2010

Aug 4, 2014

My company recently upgraded our MS Office from 2007 to 2010 (except for Access).

Previously, when I had Access 2007 and Outlook 2007, I had a process that generated 50+ dynamic emails from an Outlook template file (.oft).

The code would loop through a listbox and replace the template's default text to a string of text specific to the selection in the listbox by utilizing the Replace() function on the MailItem .HTMLBody.

Since the upgrade to Outlook 2010, the code is able to run, however, the Replace() function is no longer working; Instead, each email that is generated maintains the template's default text.

The only thing that is not working is the Replace() function, all other aspects of the code work fine.

I've provided a simplified version of the code below:

Dim myOlApp As Outlook.Application
Dim objMailMessage As MailItem
Dim stBody As String
Set myOlApp = Outlook.Application
Set objMailMessage = myOlApp.CreateItemFromTemplate("C:UsersDesktop emplate.oft")

[Code] .....

I've recreated the template file in Outlook 2010, thinking that the template created with Outlook 2007 would be the culprit, but to no avail.

What could have changed from Outlook 2007 to Outlook 2010 that would render my previously valid code ineffective?

Are there certain references I need to enable in both Access and Outlook to allow VBA in Access modify the content in an Outlook email?

View 12 Replies View Related

Modules & VBA :: Email Function Using Optional Parameters - Optional Argument Error

Aug 12, 2015

I keeping getting the error "Invalid use of Null" when i call my email function using optional parameters.

Code:
Email Me.ProjectID.Column(1), _
Me.ProjectAddress, _
Me.TaskDescID.Column(1), _
Me.TaskDescExt, _
strStatus, _
Me.TaskStatusID.Column(1), _

[Code] .....

View 4 Replies View Related

Queries :: VBA Code On Subform To Lookup Email Field On Table And Launch Email?

Jun 26, 2015

VBA Code to go in the on double_click event of a name field in a Subform bound to a table. The subform is just a copy of a data table and within the subform view, When the field "employee name" which contains e.g. John is double clicked, I would like access to Lookup and get John's email in the employee table under field "Email" and launch outlook application and insert it into the To field.

I assume hyperlinking the field can also achieve this similar to what excel does but I am fast learning that what is standard functionality in excel is a whole another story in Access..

View 3 Replies View Related

General :: How To Send A Single Email Message To All The Email Addresses In Query

Jun 2, 2014

I have a query (Access 2007) that contains a field named "email" (which contains email addresses, of course). I want to email everyone in the query and they are all going to receive the same message. My email to them doesn't have to be personalized and I don't need to collect data from the recipients. I don't even need a reply to the email I send.

View 12 Replies View Related

Modules & VBA :: Form Which Has Button To Email Data Out In Standard Email Message

Jan 15, 2014

I have a form which has a button to email the data out in a standard email message.

Private Sub Command60_Click()
Dim MyDb As dao.Database
Dim rsEmail As dao.Recordset
Dim sToName As String
Dim sSubject As String
Dim sMessageBody As String

[code]...

This works well enough, however, FIELDS 11 through to 16 contain the venue address. This is all we ll and good if every field of the venue address is populated. here are times when not all of the fields are populated, for instance, the address might only be 5 lines.I know I can do this using IIf statements on a report, but how can i achieve the same thing for the email.

View 6 Replies View Related

General :: Send A Specific Email From Outlook To All Email Addresses Within A Query

Jan 21, 2014

I have a database that I can use to create a query, grouping companies by city. I then want to send a specific email I have created in outlook to all of the email addresses in the query.I do not need to include names.

View 6 Replies View Related

Modules & VBA :: Generate Multiple Email Messages To Different Email Addresses

Jul 16, 2014

I have made a query with the name "Confirmation" and it is setup like this:

Name trainee Email Training
John John@mail.com Tr one
Mary Mary@mail.com Tr two

I also made a button in a report with the title "Send Mail" now is my goal that if i press that button automatically multiple e-mail message's will be generated with data from people in that query. So if click on that "Send Email" button i want two different mails messages generated that will be send to John@mail.com and Mary@mail.com with in the mail body their data.

View 13 Replies View Related

Modules & VBA :: Specifying Email Address When Sending Email Via SMTP

Jan 19, 2015

I am currently using vb code to send an email in Access on the click of a button. I want the database user to be able to enter the recipient in a text box [ToEmail] which is on form [GroupStockProfiler]. However, I'm unsure how to put this into my code. I currently have the following which doesn't work (unless I put a specific email after 'To'):

Private Sub Command414_Click()
Const cdoSendUsingPickup = 1
Const cdoSendUsingPort = 2
Const cdoAnonymous = 0

[code]...

View 1 Replies View Related

Forms :: Add Senders Email Address To Body Of Email

Sep 16, 2013

I want to automate an email to include the senders email addres with some text in the body of the email.

Code:
Private Sub send_mail_Click()
Dim olApp As Object
Dim objMail As Object
On Error Resume Next 'Keep going if there is an error
Set olApp = GetObject(, "Outlook.Application") 'See if Outlook is open

[Code] ....

View 3 Replies View Related

Exporting Email Addresses To Email Program

Sep 22, 2005

I have an Access database list of people, which includes their email addresses. I want to export the email addresses to Hotmail or Netscape email.

How can I do that?

View 1 Replies View Related

Modules & VBA :: Add CC Email Addresses Into Automated Email?

Aug 3, 2015

I have an automated email system (Lotus Notes) in a Access database I have created and am looking for the code needed to add up to 3 c.c addresses into an email prior to sending automatically.

The code I have to send the email to the To: individual is all working but what code I need to add and where for the c.c addresses of which there could be 1, 2 or 3. The control for To address is EmailTo = CustCopyEmail The controls for the 3 c.c emails are cc_EmailAddress, cc_EmailAddress1 and cc_EmailAddress2.

Here's the code I have:

Private Sub SEND_CC_Click()
' Set up the objects required for Automation into Lotus Notes.
Dim Maildb As Object 'The mail database.
Dim Session As Object 'The Lotus Notes session.
Dim MailDoc As Object 'The mail document itself.
Dim UserName As String 'The current users Lotus Notes name.

[code]....

View 8 Replies View Related

Modules & VBA :: Creating A Function That Counts Records And Use That Function In A Query

Dec 11, 2013

So basically I need making a function that will count the number of records from another table/query based on a field from the current query.

View 2 Replies View Related

Forms :: SUM Function Produces Error From Calculated Function

Jan 30, 2014

I have a project at hand and it's been a predecessor of mine and client has asked me to do some work on it and extend functionality - but I have not really delved into Access before and I have had to worked my way through to this final snag :/

The Main Form has one sub form. This sub form allows the user to add multiple order items i.e. qty, stock, description from records within the system - fairly straight forward.At the last column of each row is the sub total of those particular items i.e.

Qty Unit | Item ID | Total
-----------------------
2 | 1234 | 80.00
------------------------
1 | 43526 | 20.00
------------------------
> | |

So the total is a function of =[Qty Unit] * [Unit Price].Then in the Footer of this SubForm is the Sub Total

=SUM([Qty Unit] * [Unit Price])

All fine and well..... However, the additional functionality kicks in.

Lets add the additional customer_id from the Main Form. Each Item bought is dependent on the customer_id i.e. they get special prices depending on who they are.So a New table is made which has the Item ID and SpecialPriceID (of a table to define as a specialPrice) and the Price linked to this Item and Special Price category. So say that there are two groups of users "wholesale" and "nonwholesale" these would be SP_1 and SP_2 and each client is defined either one of these, and each stock item has a Price for each SP_1 and SP_2. Hopefully I've explained myself there.

Back to the SubForm. So now the Total needs to calculated differently with needed the external customer_id from the Main Form.

Code:

Function CalculateSpecialPrice(ItemID As String, CustomerID As String, Unit As Integer)
Dim SPSelect As String
SPSelect = "SELECT Price FROM [Items_SpecialPrices] WHERE"
SPSelect = SPSelect & " ItemID = '" & ItemID
SPSelect = SPSelect & "' AND SpecialPriceID = (SELECT SpecialPriceID FROM Customers WHERE customer_id = " & CustomerID & ") "

[code]....

its the sub total I just keep on getting #Error on. I have even watched (using alerts) that the correct return variable is the same as the individual rows. This is the equation I used for the SubTotal within the footer.

=SUM(CalculateSpecialPrice([Item ID], [Form]![FormName]![CustomerID], [Qty Unit]))
#Error

View 2 Replies View Related

Date Function/need Time Function

Jun 9, 2005

We have a date function that converts a text date format. Can someone help me with time function to do the same thing? We want military time. The field is like this now: txt fields.
160037
213137
224356
235716
235800
12341
21708
22732
Here is the date function we use:
Function f2Date(strDateOld As String)
Dim strDate As String, strMonth As String, strYear As String
strMonth = Mid(strDateOld, 5, 2)
strDate = Right(strDateOld, 2)
strYear = Left(strDateOld, 4)
f2Date = strMonth & "-" & strDate & "-" & strYear
f2Date = CDate(f2Date)
f2Date = Format(f2Date, "mmmm d yyyy")
End Function

View 9 Replies View Related

Now Function To Convert To Date Function

May 25, 2006

Hi all,

I need a little help. In my DB, I have a command button set up (I was tired of typing in dates) for date, but I used the Now function, which also gives me the time.

Now I have over 3000 subrecords of the main ones. I now need to queries transaction for that specific date, but it also retrieves the time.

I tried to go back and change the NOW to DATE in VB, but the code does not run.

How do I change all records that have date and time (using NOW function) and only click that command button to show only the date (mm/dd/yyyy)?

Thanks in advance.

View 1 Replies View Related

DB And Email

Jun 11, 2005

I have a Access database with a field that lists emails. What I want to do is somehow tie it to my outlook so that I can email all of the people in that list. Does anyone know how to accomplish this?


Thanks.

I have Access 97 and outlook 2000.

View 1 Replies View Related

Email

May 2, 2006

Hi,

Here is a good one thats got me stuck for ages.

I have made an email facility in my database and I have set the message box as a memo for the Unlimited Characters. There are a number of templates that the user can select but I cannot get the simple text to show formatting (as in rich text style). I have had a look at RTF syntax but cannot work out how to tag the simple text to show it once it has been emailed.

Can any one help?

thanks

View 1 Replies View Related

Email

May 24, 2007

I have been workign with this email piece and am sort of close but not close at the same time....

WHat I want to do is click a button on a form and have it open up my email and force emial addresses in the "To:" section of the email...

I can accomplish this with:

Dim stDocName As String
stDocName = "Mass_Mailing_Report1"
DoCmd.SendObject acReport, stDocName, acFormatTXT, "EMAIL ADDRESS", , , "SUBJECT LINE", , True

But that requires me to maunally update the email addresses each time a user changes or is added...
What I want to do is read a table and grab the address from a field in that table. So as the table grows, changes, shrink the email portion is seemless.
Does anyone have an ideas as to how I can accomplish this?

Thanks....

View 7 Replies View Related

Email Failure

Jun 15, 2005

have a DB which is working fine on most PCs (approx 15 users) I do however have a problem sending emails from some machines (using a macro to do the send object as example below) The mail program used is Outlook 2000 / 2003

DoCmd.SendObject acReport, "Returns Notice", "SnapshotFormat(*.snp)", "to a defind list", True, ""
This works fine BUT on most machines but on a couple we get a fail message when attempting to send, this message is unspecific. I cannot find any different settings on the machines in question, the op system is 2000 / XP.

I operate the same program on my PC running XP prof servpk 2 and although 99% of the time the emails go through without issue I do sometimes have the same problem. Re-booting does not resolve it! and I can find no trend as to why I have the problem.
Any thought or advise welcome.

View 2 Replies View Related

Sending Email

Nov 30, 2005

I am useing DoCmd.SendObject to send emails - however I get outlook opening an email with my To, BCC fields filled in , however I am stuck in the new email screen - ie can't get to a previuos email to copy and paste text - like it is dialog?

Is there any way around this.

Thanks Paul

View 4 Replies View Related

Question About Email

Mar 21, 2006

Hello,
I would like to send e-mails with a customized letter paper that i want to place as background in the e-mail body. I have created a htm file (Logo + Enterprise header) , if i insert the file manualy with Outlook when when creating a message that works, i tried to
place my file + path in the last parameter of the SendObject command, when i execute i have no error but the paper is not inserted in the mail.
Just i want to do is to have the logo + name + adress etc... then place my body content under this header.
Can someone tell me what's wrong or another way to do that.
Thanks in advance.
Vincent

Command i used:

DoCmd.SendObject acSendNoObject, , acFormatHTML, rs!Email, , , gObjMes, gTxtMes, false,"C:.....MyLetterPAper.htm"

View 7 Replies View Related

Email With Access

Mar 26, 2006

I just want to click on an email in my forms folder and have outlook open up with the recipients name in the to: field any help will be appreciated.

Thanks

chris

View 2 Replies View Related

Email Merge

Aug 20, 2006

Hi,

I have been searching for related posts to this question; however, there either were not any posts that answer it or I can't find any.

Basically, I need to do something exactly similar to mail merge, but with email. Is that possible in Access?

Any help will be very much appreciated.
B

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved