LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #13   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11
Default Auto email from excel with custom subject

Hi....finally I managed to find what was wrong......In my own code, I
was trying clear the cells myself.....and then wondering why the fields
are coming blank....

Me.txtcompno.Caption = ""
Me.txtcustomer.Value = ""

I removed above 2 lines from my code and now it works like dream!

thanks ron for your patience and help!

I am still looking for suggestions on the "Sender Name" problem.

Cheers




Vikram wrote:
Hi Ron

I just figured out that, this works if I create a separate
commandbutton on the userform to send email. But as soon as I add this
code to the additem code (shown below) it starts playing up. It opens
email page fine, but the subject goes blank...and only shows default
text.

Is there any way, I could use a checkbox or something that will allow
me to do both the things : 1. Add record to the database 2) send email
with custom subject, with one commnd button instead of two?

cheers

================================================== ===========

Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("ComplaintData")

'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row


'copy the data to the database
ws.Cells(iRow, 1).Value = Me.txtcompno.Caption
ws.Cells(iRow, 2).Value = Me.txtdate.Caption
ws.Cells(iRow, 3).Value = Me.txtcustomer.Value
ws.Cells(iRow, 4).Value = Me.txtconper.Value
ws.Cells(iRow, 5).Value = Me.txtproduct.Value
ws.Cells(iRow, 6).Value = Me.txtbatch.Value
ws.Cells(iRow, 7).Value = Me.txtcategory.Value
ws.Cells(iRow, 8).Value = Me.txtdescription.Value
ws.Cells(iRow, 9).Value = Me.txtAM.Value

'clear the data
Me.txtcompno.Caption = ""
Me.txtcustomer.Value = ""
Me.txtconper.Value = ""
Me.txtproduct.Value = ""
Me.txtbatch.Value = ""
Me.txtcategory.Value = ""
Me.txtdescription.Value = ""
Me.txtAM.Value = ""

Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String

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

With OutMail
.To = "
.CC = ""
.BCC = ""
.Subject = "A new Complaint No." & Me.txtcompno.Caption & " has
been entered."
.Body = "A new Complaint No." & Me.txtcompno.Caption & " has
been entered for " & Me.txtcustomer.Value
.display 'or use .Display
End With

Set OutMail = Nothing
Set OutApp = Nothing
Unload Me

end sub
================================================== ===========


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Stop excel from dropping the 0 in the beginning of a number? Rosewood Setting up and Configuration of Excel 12 April 4th 23 02:12 PM
Excel 2007 Custom Error Bars BuzzinHornet Excel Discussion (Misc queries) 4 June 14th 06 10:47 PM
Custom error bars excel 2007 BuzzinHornet Charts and Charting in Excel 2 May 30th 06 02:21 AM
Excel email address routing matt_gooner Excel Discussion (Misc queries) 1 May 23rd 06 07:09 PM
Can you enable auto complete from a custom list in Excel? poaq Excel Discussion (Misc queries) 1 March 17th 05 11:28 PM


All times are GMT +1. The time now is 10:53 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"