Results 1 to 3 of 3

Thread: Email sending whit VB,

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2001
    Posts
    259

    Email sending whit VB,

    Hi,

    I need to program something but i don't know if it is possible. What i need to program is that when i send a email whit Outlook i need that outlook send a copy of the same email to another email adres, So that the administrator recieve a copy from every sent email. Is that possible in Outlook? or better can ik program it self whit vb?

    Is it possible whit vb to delete automatical all the emails in the "sended box or in box" from outlook?


    Thanks for your help.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Set a reference to the MS Outlook Object Library and use this:
    VB Code:
    1. Private Sub SendMessage(DisplayMsg As Boolean, Receiver As String, Optional
    2.     AttachmentPath)
    3.     Dim objOutlook As Outlook.Application
    4.     Dim objOutlookMsg As Outlook.MailItem
    5.     Dim objOutlookRecip As Outlook.Recipient
    6.     Dim objOutlookAttach As Outlook.Attachment
    7.     Dim CallDescription As String
    8.  
    9. ' Create the Outlook session.
    10.     Set objOutlook = CreateObject("Outlook.Application")
    11.  
    12. ' Create the message.
    13.     Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
    14.  
    15.     With objOutlookMsg
    16. ' Add the To recipient(s) to the message.
    17.         Set objOutlookRecip = .Recipients.Add(txtSendTo.Text)
    18.         objOutlookRecip.Type = olTo
    19.  
    20. ' Add the CC recipient(s) to the message.
    21.         Set objOutlookRecip = .Recipients.Add("Administrator Account")
    22.         objOutlookRecip.Type = olCC
    23.  
    24. ' Set the Subject, Body, and Importance of the message.
    25.         .Subject = "Replace this String With your subject Or variable"
    26.         .Body = "replace this String With your subject Or variable"
    27.         .Body = .Body & vbCrLf & "In this manner you can create a body larger than 256 characters"
    28.  
    29. '.Importance = olImportanceHigh  'High importance
    30.  
    31. ' Add attachments to the message.
    32.         If Not IsMissing(AttachmentPath) Then
    33.             Set objOutlookAttach = .Attachments.Add(AttachmentPath)
    34.         End If
    35.  
    36. ' Resolve each Recipient's name.
    37.         For Each objOutlookRecip In .Recipients
    38.             objOutlookRecip.Resolve
    39.         Next
    40.  
    41. ' Should we display the message before sending?
    42.         If DisplayMsg Then
    43.             .Display
    44.         Else
    45.             .Send
    46.         End If
    47.  
    48.     End With
    49.  
    50.     Set objOutlook = Nothing
    51. End Sub

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2001
    Posts
    259

    Hack

    Hi HACK,

    thank you verry mutch for replying to my question. But that example what does it exactly? how must it be run?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width