Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Forward Specific E-mails At Certain Times In Outlook Using VBA

I'm trying to use VBA to forward all certain e-mails, received from specific e-mail addresses only, when received outside of office hours.

ie. On a Saturday, Sunaday, or outside of 8am-6pm Monday to Friday, I'd like e-mails from email1@domain1 and email2@domain2 to be forwarded to an alternate e-mail address.

I've used VB and VBA before, just never with Outlook, and am looking for some assistance/guidance. I've searched the Net already, but can't get my code to work.

Also, I already have quite a lot of rules runnings to filter e-mails into specific folders. So, would this run before the rules pickup the e-mail, or can I check all folders for new mail from these addresses?

Here's what I currently have:

Public WithEvents myOlItems As Outlook.Items

Public Sub Application_Startup()
' Reference the items in the Inbox. Because myOlItems is declared
' "WithEvents" the ItemAdd event will fire below.
Set myOlItems = Outlook.Session.GetDefaultFolder(olFolderInbox).Items
End Sub

Private Sub myOlItems_ItemAdd(ByVal Item As Object)
' If it's currently not between 8:00 A.M. and 6:00 P.M.
If Time() < #8:00:00 AM# Or Time() > #6:00:00 PM# Then
' Check to make sure it is an Outlook mail message, otherwise
' subsequent code will probably fail depending on what type
' of item it is.
If TypeName(Item) = "MailItem" Then
' Forward the item just received
Set myForward = Item.Forward
' Address the message
myForward.Recipients.Add "alternate@domain"
' Send it
End If
End If
End Sub

Thanks for any help given


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Right-click Context Menu To Forward Email To A Specific Address In Outlook 2000...

I'm running Outlook 2000, and I wanted to be able to right-click on any email I've received (in any of various folders) and select a menu item that says 'Forward', and it will be forwarded to an email address that I'll specify in the VBA code.

I saw on this forum (at ) some VBA code that allows forwarding emails, and set it up so a button on the toolbar called the send function, but it didn't do anything (no error, no email forward, nothing). I'm not sure why... I followed the author's directions exactly. Perhaps it's my security settings (Outlook set to use Restricted Zone, Restricted Zone set to disable everything). I can not lower security to accomplish this email forwarding thing, though.

Anyway, I'm a VBA oldie who's forgotten most of it, so I'm for all intents and purposes a VBA newbie. It's amazing how much you can forget when you stop using a programming language.

Thanks for your help.


Outlook VBA Forward Mailitem

I want to do the following:
1. I klick onto a mail in my inbox to select it.
2. I run a sub routine to automatically do two things:
2a) Add a sentence to the mailbody
2b) Forward the mail to two usergroups.

I have the following:

Sub ReplyITT()

Dim mynamespace As NameSpace
Dim myforward As MailItem
Dim myfolder

Set mynamespace = Application.GetNamespace("MAPI")
Set myfolder = mynamespace.GetDefaultFolder(6)

Set myforward = GetCurrentItem()

myforward.Body = "added Text to the mailbody" + vbCrLf + myforward.Body
myforward.Recipients.Add "verteiler - ith"
myforward.Recipients.Add "verteiler - itt"
myforward.Send '########## here I get the errormessage

End Sub

' Function GetCurrentItem() written by Buck Pavia (
Function GetCurrentItem() As Object
Dim objApp As Application
Dim objSel As Selection
Dim objItem As Object
Dim objmailItem As MailItem

Set objApp = CreateObject("Outlook.Application")
Select Case objApp.ActiveWindow.Class
Case olExplorer
Set objSel = objApp.ActiveExplorer.Selection
If objSel.Count > 0 Then
Set objItem = objSel.Item(1)
Set objmailItem = objSel.Item(1)
End If
Case olInspector
Set objItem = objApp.ActiveInspector.CurrentItem
Set objmailItem = objApp.ActiveInspector.CurrentItem
Case Else
' can't handle any other kind of window
End Select

'Set GetCurrentItem = objItem
Set GetCurrentItem = objmailItem

Set objItem = Nothing
Set objSel = Nothing
Set objApp = Nothing
Set objmailItem = Nothing

End Function

I call the ReplyITT which is located behind a button after I selected the mail.

And then I get an error message like :

Runtimeerror '-2114519035 (81f70005)':
You do not have the propper rights to send the message in the name of the provided user.
(well I get the error message in german: Sie besitzen nicht die Berechtigung, die Nachricht im auftrag des angegebenen Benutzers zu senden.)

If I manually forward the message, I have no problems with it.
If I change the ReplyITT a bit to simply use the first mail (it somehow only works with the first mail in the list and I have no chance to get the selected mail of my inbox) then it works too. If I have written the mail (for testing to myself) then too.
Just for the upper code and not myself written mails I get the error.

I would be happy if someone could have a look into it. I bet its just a tiny change that has to be done. I just dont know what.

Thanks a ton!


Run Sub At Specific Times Of The Day
I have constructed a form in which I want to run continuously all day for months. I want to run a subroutine at certain times of the day. I was wondering about using a timer, but I am not sure how to use them, or is would there be a better way to do it. I have looked through the forums and I see people using intervals, but to run continuously I don't think using intervals would work. Could someone help me out ASAP.

Outlook: Ope.n .msg From Directory And Forward But Not As Attachment
I need to open a .msg file from a (network) directory and forward it (or even better get acces to its body t crate a new mail)

It seems to work only I always end up with my orriginal mail as an attatchment.

Anyone know how to do this?

Outlook -email Item Forward
im making a custom form using a message form in outlook, i edited the compose and read page, the problem is i want outlook to display the read page when the user forwards it, right now it shows the compose page.... is there any way to do this? thanks

Macro To Forward Outlook Appointment As ICalendar
I need to write a VB macro that will performs the following.

1. User opens an Outlook Calendar Item.

2. Macro should take the active item and Forward as ICalendar to a specific email address.

I am only trying to forward the Active Item, not multiple calendar items.
The email address can be hard-coded.

Can someone tell me how to do do this?


Forward Outlook Emails In Original Format
I'm attempting to change the reply format in Outlook to always use HTML. At my workplace, Outlook 2003 is configured to display all incoming emails as plain text. I can revert the display back to the original format by right-clicking on the information message bar in the viewing pane ("This message was converted to plain text.") and selecting "Display as HTML". And yes, the message handling checkbox can't be unchecked to allow the original format to display.

I currently have code in ThisOutlookSession that allows me to forward all emails as HTML. When the original email is displayed in HTML format, the forwarded email retains all the HTML code associated with it. If I forward from the viewing pane where I haven't selected "Display as HTML", the plain text is converted to HTML, but all formatting is lost.

Is there a method to evaluate the underlying BodyFormat without regard to what Outlook is currently displaying?

How To Forward Outlook E-mail Using Excel / VBA Script

I have the undermentioned VBA script to import outlook e-mails into an excel sheet.

Now I also want to forward each of the messages who are imported to an e-mail adress. What do I need to put extra in my script? Please help me. Thanks!


Dim OLF As Outlook.MAPIFolder, CurrUser As String
Dim EmailItemCount As Integer, i As Integer, EmailCount As Integer

Dim appOutlook As Outlook.Application
Dim ns As Outlook.NameSpace
Dim Inbox As MAPIFolder
Dim MoveToFolder As MAPIFolder
Dim strSubject As String
Dim strSender As String

Set appOutlook = CreateObject("Outlook.Application")
Set ns = appOutlook.GetNamespace("MAPI")
Set Inbox = ns.GetDefaultFolder(olFolderInbox)

Set OLF = GetObject("", "Outlook.Application").GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
EmailItemCount = OLF.Items.Count
i = 0: EmailCount = 0

While i < EmailItemCount
i = i + 1

With OLF.Items(1)
EmailCount = EmailCount + 1
Mail_subject = .Subject
Mail_body = .Body
mail_from = .SenderName
.UnRead = False

End With

Help With Making Program Run At Specific Times
I wanted to have my program execute a command every day at a certain time. But i dont know how i would quite go about doing that. thanks

Sending Mails Not Via Outlook
This code lets me mail stuff out via outlook..

Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(0)
With objOutlookMsg
.To = "...@..."
.Cc = "...@..."
.Subject = "..."
.body = "..."
.HTMLBody =
.Attachments.Add ("")
.Send 'Let´s go!
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing

but what im trying to do is to make it so the user can send out a mail without having to open his/her default mail browser.. how??


Outlook Form E-mails
I am trying to create a form e-mail in outlook...

However, it doesn't look like it uses VB or VBA to code it...some kind of scripting....

Any ideas on where to find syntax for this? Or better yet, how I can use VB or VBA with it?

Save FW Or RE Mails In Outlook

i want to save emails from outlook to disk as a .msg file.
The code i use is:

Public Sub Email_To_HDD(ByVal mail As MailItem)

mail.SaveAs "c: est" & mail.Subject & ".msg", olMSG

MsgBox "Done"

End Sub

It works fine with "normal" mails, but not with forwarded and replied mails. The file which is created is 0 bytes and its name is FW or RE.

I hope somebody can help me.

Outlook Archive Mails
Hi all,

Is there any way in VB 6.0 that I can read each mail in Outlook archive and print each mail in a separate text file. If possible can some one give me code, that I can customise to my needs.

Thanks in advance,

In Which File Are The Mails From Outlook 98?
Where I can find the emails in Outlook 98?
I am interested to know ALL files where are traces from them ...


Sending E-mails With Outlook
hi!! I need to run Outlook's New Message window, and place in the "To" text box, an e-mail address selected from the prog I am making. Can u tell me how can I do it?? Thank you!!

How To Read Outlook Mails Using VB
Hi to all,
wishing you a wonderful day

Is it possible to read outlook mails from VB?


How To Read Mails From Outlook In VB.NET
Pls tell me how can i read mails in inbox from Outlook in VB.NET using MAPI. I get the list of senders and unread senders but i am unable to read th email.Pls help.

Create Mails In Outlook

how can i create mails in the inboxfolder in outlook? i can't set "sendername" of the mailproperty :-(
and i want to create mails for a syncprocess with a SQL-database!

can u help me?


Import Mails To Outlook

how can i import csv-files to outlook(inboxfolder) in vba? is it possible?


Reading E-mails In Outlook
I seached for this, but couldn't find a similar question, so here it gous:

How do I send/read e-mail messages from Outlook 2002?

Here's what I want it for - I wanna make a multiplayer game that communicates between clients over e-mail. Ya, I know that there are better ways, but I have to use this to bypass network secury on my school's network.

Naturally messages will be encripted, but for now I just need to know how to send and recieve them.

Any help would be appretiated

Save Mails From Outlook
How can I write a program witch saves all my Mails in my Inbox. In Outlook I can't save all mails together, so it would take a long time to save all the mails to disk.

Does anyone has made something like this.

mfG Pueromane

Outlook Mails As An Attachment
Could anybody give me a pointer as to how to extract the list of CC:'ed mail address's that are contained in an email message that is contained inside another email message as an attachment in outlook!

Hope that makes some sense.

So in otherwords, I recieved an email that has an email as an attachment and I want the list of CC:'ed email address's from that email.

Sort Mails In Outlook
I am writing a program where i need to access the mails in the outlook ... I am able to read the mails But i need them to be sorted before i read then

Any Idea How To Sort The Mails on the Sent Field In descending Order.

Date&&Time Experts! Checking Data For Specific Times Of Day
I am stuck trying to run a procedure that:
Finds the entry of Col A at Row J (in custom date format dd/mm/yyyy h:mm) and checks to see if the time field is in between 1:30am and 3:30am, or in between 7:30am and 10am.
If the case is true, then it will continue to the next procedure, otherwise if it's false it will increment J and redo the check.

Since the data is not in std. format (h:mm) field, I need to use the custom format and I do not know how to seperate the time from the date since I am only comparing the time components and do not need the date component. On top of that, with my inexperience in coding, how would I write a DO WHILE LOOP for instance...I don't even know where to begin be checking for a time that meets the above criteria.


Automate Copying Of Mails In Outlook
how can i automate copying of mails in outlook public folders to C drive?

Extract Mails From Outlook Express
Hi there,

i've got outlook express with about 10.000 Mails spread over ~200 folders. I want to save all of them as separate .eml-Files to my harddisk (this is usually done via "file", "save as").

Using VB's sendkeys is no option, because I've to loop through the folders - and it's not very save of course.

Maybe there is another way to do this (OLE?) which I dont know.

Thanks in advance for any help!


VBA HELP! Saving Outlook E-Mails To .txt Files
I am trying to use VBA to save the body's of all the emails in a particular sub-folder to a directory on my hard-drive. When I run my code I recieve the following error

Run-Time Error - '2147467259 (80004005)':

Internal Application Error

Here is the code that I am using. Any help would be greatly appreciated.

Public Sub SaveIt()

Dim objMapiName As Outlook.NameSpace
Set myOlApp = CreateObject("Outlook.Application")
Set objMapiName = myOlApp.GetNamespace("MAPI")

Set folder = objMapiName.GetDefaultFolder(olFolderInbox)
Set subfolder = folder.Folders("TOP OPEC")

For i = 1 To subfolder.Items.Count

Set myItem = subfolder.Items.Item(i)

myItem.SaveAs "C:TOP OPEC" & myItem.Subject & ".txt", olTXT


End Sub


Reading Outlook Express Mails
I would want my VB application to read an Outlook express mail session that has not been opened by my application. (i.e. If i manually open Outlook Express and select a mail to be read, my apllication should be able to read the subject and message of the selected mail).

Microsoft does not define any object hierarchy to read Outlook Express mails. Is there any way to solve this problem?.

What Control Can I Use To Display E-mails Like Outlook
Hi Guys,

Im planning to use a treeview to display Inbox and Outbox for example.

What control can I use to display the actual emails. Is there a nice free grid that someone can point me to please. Thanks in advance

Moveing Mails Using A Macro Within Outlook?
I am useing Outlook 2000 and I am wanting to create a button that would automaticaly move the email item(s) I have selected, wherever I am, to a certain folder. I thought this may be possible by writeing a macro to do this and then assign this macro to a button. The only problem is that I do not have any idea how to do this. I presume this is probably quite a simple task so if anyone I would appreciate it.

Off Topic - Animations In Outlook E-mails

Anyone have any idea how to insert animated gifs into MS Outlook (not
outlook express) e-mails ???


Darren Logan BSc (Hons)
Development engineer


Tel: +44 (0) 1223 434854Fax: +44 (0) 1223 434895
Switchboard: +44(0) 1223 434800
UKAS Accredited: Calibration No. 0179
ISO 9002 Through BSI Certificate No. Q6284

e-mail address: mailto: email@removed
Internet Address:

Reading Mails From Outlook Express
please any one can help me to read the inbox mails and sent items from outlook express.
i am using the mapi control. i can only send the mails by using mapi. i want to list the all inbox mails and sent mails in a grid.
please help me to read the inbox mails and sent items from outlook express.

vijiemail me

How To Retrive My Mails From Outlook Express (in Vb)
how to catch my mail from out look through vb.
i want put taht mail in my text box.
advance thanks

Sending Mulitple Mails In Outlook Using Vb
what is multiple recipient memeber..

another question while sending the mail can i disable the reply button

This Code Worked For Sending Mails Without Using Outlook

I struggled a lot to send mail without using outlook and the code below is the final one that I used to send mail with attachment.

It may be useful for those who are seeking similar solution

VB Code:
Dim strTo As StringDim strFrom As StringDim attach As StringDim iMsg As New CDO.MessageDim i As IntegerDim FldsDim file As StringDim iConf As New CDO.Configuration  Sub Sendmail() Dim msgfile2 As StringDim filex As StringDim sArr(10) As String   On Error GoTo error_olemsgSet Flds = iConf.FieldsWith Flds    .Item(cdoSendUsingMethod) = cdoSendUsingPort     .Item(cdoSMTPServer) = "<<Your exchange server name>>"    .Item(cdoSMTPConnectionTimeout) = 30    .UpdateEnd With With iMsg    Set .Configuration = iConf    .To = emailid    .From = "Some random text-As you wish"    .Subject = "here goes the subject"    msgfile2 = "Please find the message" & vbCr & vbCr & "    " & vbCr & vbCr    msgfile2 = msgfile2 & "This is an Automatic email, Please do not “REPLY” to this email. " & Chr(vbKeyReturn) ' create the recipient     .TextBody = msgfile2        For i = 1 To 3        Select Case i        Case 1:            sArr(i) = file1        Case 2:            sArr(i) = file2        Case 3:            sArr(i) = file3        End Select        If IsNull(sArr(i)) = False Then           .AddAttachment "c:" & sArr(i)        End If    Next i    .Send    End With     Set iMsg = NothingSet iConf = NothingSet Flds = NothingExit Sub

How To Get All Mails From Outlook Express To A Stand Alone VB Application
hello to all of you,
Actually my problem is that My office close on saturday and sunday. in those days we receive a bulk of mails on our office mail id by which our server hangs.
my boss just want to built an application in which we integrate our mail id and select a particular day and press delete option so that load over the server will reduce.

i hope i am able to explain my problem.
help me by your valuable codes and suggestions.

thank you very much.

Count E-mails And Send Data To Outlook
Hello all,

I want to count how may e-mails are in several outlook inboxes and send the info to an excel sheet.

so the excel sheet will look like this

personal inbox:- 23 mails
company inbox1:- 78 mails
company inbox2:- 17 mails

so on so forth...

im not sure how to do this, im guessing its not too complex the main thing im unsure of is knowing how to kind of declare the name of the inbox??

also i would require it to only take mails arriving on "todays date" read and unread

If someone knows a way of doing this task please help!


Edited by - gazvbanewb on 8/17/2005 9:30:47 PM

Converting Eudora Mails To Outlook Format
Hi all,

I am using both eudora & microsoft outlook mail clients. i have some mails in eudora and this mails should i have to take it to outlook by manual coding.
will any one have face the same problem with solution, Pls. give me coding of its.


How To Save Mails In A Different Folder Instead Of Drafts In Outlook
i have written an automailr code using mapi control. but problem is that i want to save this mails in a different folder in stead of drafts folder using vb. sorry i have forgotten to mention, i am using outlook exp.
so pls help me....
its very urgent

Outlook Blocking Sending Of Mails From MAPI For 5 Seconds ?

I wrote an application that send e-mails to various clients from an Access database. I used MAPI in the code to enable this. My problem however is that Outlook blocks the mail with the message box that comes up to say "A program is trying to automatically send e-mail on your behalf...."

You need to click on OK to continue which makes the efforts of my applications futile as it was supposed to automate the whole mailing process.

Is there a way to get past this ?

I need to have the mails sent via Outlook becuase my Outlook in turn sends it to a port where it goes through an inline GnuPG application that digitally signs and or encrypt the message. So I must either be able to drop the mail in Outlook like now or I must be able to send the mail to a port on my local pc so that the inline GnuPG app. can pick it up.

Any help will be appreciated.


Sending Rich Text To Outlook Mails In Office XP
I have a program which copies contents from a rich text box and passes the contents to an Outlook mail object.
For Office 2000 if I write ".textRTF" instead of simply ".text" then in Outlook mail the formatting is preserved.
But this doesnt work with Office XP.

Any help will be appreciated.

Searching For And Moving E-mails In An Outlook PST From A List In Excel Using VBA
Hi there,

I was hoping someone might be able to give me some guidance - I have the task of sorting various e-mails in a master PST, into seperate folders based on a list of e-mail addresses which have been extracted from the PST, and are stored as a simple Excel workbook.

the current list of addresses reaches around 5000 items, and so doing this manually would be a extremely burdensom task - I was hoping that this would made fairly simple by the use of a VBA marco, and it could be easily recorded however Outlook does not allow the recording of macros. I've also been reviewing various samples, but cannot make head nor tail of what needs to be done, and my experience with VBA is fairly limited.

Basically what needs to happen is:
- vba selects the e-mail address from a cell in Excel, and copies this value
- changes to Outlook, and performs a search on the Inbox for the copied value (e-mail adress) as the sender, and then moves any e-mail item found with this value to a seperate folder
- goes back to Excel, and repeats the process to select the next cell's value.

If anyone would be able to help or provide some guidance or sample code, it would be greatly appreciated!

Best regards,

Saving Outlook Received Mails To Access Or File
I can't seem to find a namespace or the appropriate objects to copy my outlook emails to a file access or even SQL DB. HAs anyone done that?


Read Mails From The Inbox Folder Of Outlook Express
i want to know how to read mails from the inbox folder of outlook express and not microsoft outlook.
i was able to do with micorsoft outlook but unable to do with outlook express.

How To Read Mails From Exchange Server Without Accessing Outlook (with Attachment)?.
Hi all,

Does any of your application using SMTP to read mails from the exchange server. I need to read mails without using the outlook. I need to process the attachments also. If any of you guys have any solutions, please do reply or mail to ""

Any help in this regards is highly appreciated.

Thanks and regards,

How To Avoid Outlook Express Dialog Box While Sending Mails To Multiple IDs

I have written the following code to send emails to 1000 ids. everytime i have to click "Send" button. but for 1000 times it is ridiculous. please help me.

The code is as :

Option Explicit

Private Sub Form_Load()
    Me.Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2
    lstSendTo.Enabled = False
    lstSendTo.Visible = False
    txtSendTo.Enabled = True
    txtSendTo.Visible = True
End Sub

'Accept Sender(s) Mail_ID into Text Box
Private Sub txtSendTo_GotFocus()
    txtSendTo.SelStart = 0
    txtSendTo.SelLength = Len(txtSendTo)
End Sub

'Selecting Mail_ID(s) from the File into List Box
Private Sub cmdLoadList_Click()
    Dim rs As ADODB.Recordset
    Dim cnn As ADODB.Connection
    Dim myPath As String
    Dim fld As ADODB.Field
    Dim fldCat As String
    Dim errhndl As Error
    On Error GoTo errhndl
    txtSendTo.Text = ""
    txtSendTo.Enabled = False
    txtSendTo.Visible = False
    lstSendTo.Enabled = True
    lstSendTo.Visible = True
    Set rs = New ADODB.Recordset
    Set cnn = New ADODB.Connection
    CommonDialog1.Filter = "(*.xls )/ *.xls"
    myPath = CommonDialog1.FileName
    cnn.Open "Driver={Microsoft Excel Driver (*.xls)};DBQ=" & myPath & ";ReadOnly=1"
    rs.Open "SELECT * FROM [Sheet1$]", cnn
    Do While Not rs.EOF
        If IsNull(rs(0)) Then
            Exit Do
        End If
        lstSendTo.AddItem rs(0)
    If Err.Number <> 0 Then
        If Err.Number = -2147217842 Then
            MsgBox "You have not selected file... Please", vbInformation, "Mailing"
            MsgBox Err.Description
        End If
    End If

End Sub

'To Attach the File as Attachment
Private Sub cmdAttach_Click()
On Error GoTo errhndl
    Dim fileAttach As String
    CommonDialog1.Filter = "(*.* )/ *.*"
    txtAttachment.Text = CommonDialog1.FileName
    CommonDialog1.CancelError = True

    If Err.Number <> 0 Then
        If Err.Number = 32755 Then
            txtAttachment.Text = ""
            MsgBox Err.Number & " " & Err.Description
        End If
    End If
End Sub

'To Load Text in the Message Area
Private Sub CmdLoadText_Click()
    On Error GoTo errhndl
    Dim BodyMsg As Long
    Dim myPath As String
    Dim FileText
    Dim FileObj As New Scripting.FileSystemObject
    Dim intIndex As Integer
    CommonDialog1.FileName = ""
    CommonDialog1.Filter = "Text Files (*.txt )/ *.txt"
    myPath = CommonDialog1.FileName
    Set FileText = FileObj.OpenTextFile(myPath)
    txtMessage.Text = FileText.ReadAll
    If Err.Number <> 0 Then
        If Err.Number = 32755 Then
            txtMessage.Text = ""
            MsgBox Err.Number & " " & Err.Description
        End If
    End If
End Sub

'Sending Mail
Private Sub cmdSend_Click()
    Dim intIndex As Integer
    On Error GoTo ErrHandlr

    'For Text Box
    If Trim$(txtSendTo.Text) <> "" Then
        MAPISession1.DownLoadMail = False
        MAPIMessage1.SessionID = MAPISession1.SessionID
        MAPIMessage1.RecipAddress = Trim$(txtSendTo)
        MAPIMessage1.MsgSubject = txtSubject
        MAPIMessage1.MsgNoteText = txtMessage
    If txtAttachment.Text <> "" Then
        MAPIMessage1.AttachmentPathName = Trim$(txtAttachment.Text)
    End If
        MAPIMessage1.Send False

        MsgBox "Message Sent", vbInformation, "Mailing"

        txtSendTo.Text = ""
        txtSendTo.Enabled = True
        txtSendTo.Visible = True
        lstSendTo.Enabled = False
        lstSendTo.Visible = False

    End If

    'For List Box

    If lstSendTo.ListCount > 0 Then
        For intIndex = 0 To lstSendTo.ListCount - 1
            MAPISession1.DownLoadMail = False
            MAPIMessage1.SessionID = MAPISession1.SessionID
            MAPIMessage1.RecipAddress = Trim$(lstSendTo.List(intIndex))
            MAPIMessage1.MsgSubject = txtSubject
            MAPIMessage1.MsgNoteText = txtMessage
            If Trim(txtAttachment.Text) <> "" Then
            MAPIMessage1.AttachmentPathName = Trim$(txtAttachment.Text)
            End If

            SendKeys "{ENTER}"
            MAPIMessage1.Send False

    End If

    If Err.Number <> 0 Then
        MsgBox Err.Description
    End If

        lstSendTo.Enabled = False
        lstSendTo.Visible = False
        txtSendTo.Text = ""
        txtSendTo.Enabled = True
        txtSendTo.Visible = True
End Sub

'To clear the Controls in the Form
Private Sub cmdClear_Click()
    Dim Ctl As Control
    For Each Ctl In Me.Controls
        If TypeOf Ctl Is TextBox Then
            Ctl.Text = ""
        End If
        If TypeOf Ctl Is ListBox Then
            lstSendTo.Enabled = False
            lstSendTo.Visible = False
            txtSendTo.Enabled = True
            txtSendTo.Visible = True
        End If
End Sub

Private Sub cmdClose_Click()
    Unload Me
End Sub

Download Mails From Gotmail And Yahoo Mails
Dear fellows
I want to develop a VB6 application which can download mails from hotmail and yahoo mail without using outlook express
any one can help me???????????

Import E-Mails From Outlook To Access, And Read Them From Access?
How do I import E-Mails from specified folder in Outlook to Access. I want to read the imported mails from Access also?
How do I do that?

Import E-Mails From Outlook To Access, And Read Them From Access?
How do I import E-Mails from specified folder in Outlook to Access. I want to read the imported mails from Access also?
How do I do that?

Copyright © 2005-08, All rights reserved