Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2004

    Unanswered: send mail from visual basic

    I use the following code to send a e-mail from vb, my e-mail client is outlook
    Dim email, bool, str, datum As String
    Dim OutApp As Outlook.Application
    Dim OutMail As Outlook.MailItem
    Dim wb As InternetExplorer
    Set wb = WebBrowser1
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(olMailItem)
    txt = "<table><tr><td>my message</td></tr></table>"
    txt = "<HTML><HEAD></HEAD><BODY>" & txt & "</BODY></HTML>"
    With OutMail
    .To = ""
    .CC = ""
    .BCC = ""
    .Subject = "my subject"
    .Body = str
    End With
    Set OutMail = Nothing
    Set OutApp = Nothing

    But in the head of the mail I have the following lines:

    Date: Sun, 5 Dec 2004 21:09:35 +0100
    Message-ID: <002501c4db06$579d2660$8c7ba8c0@dillb26skgpmhl>
    MIME-Version: 1.0
    Content-Type: text/plain;charset="Windows-1252"
    Content-Transfer-Encoding: 7bit
    X-Priority: 3 (Normal)
    X-MSMail-Priority: Normal
    X-Mailer: Microsoft Outlook, Build 10.0.2627
    Importance: Normal
    X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409

    How can I remove this from my e-mail??

    thank you in advance

  2. #2
    Join Date
    Nov 2004

    try this

    this is the code I use (modified) I haven't seen the msgs you mention on your post

    Option Explicit
    Public mailTo As String
    Public mailCC As String
    Public mailSubject As String
    Public fileName As String
    Public mailBody As String
    Public mailSignature As String
    Public mailAttachment As String
    Public matchFile As String
    Public WaitConfirmation As Boolean
    Public fileCriteria As String
    Public updateCommand As String
    Public connStr As String  
    Public Sub Main()
    '***Create email and send it or display it
        Dim OLF As Outlook.MAPIFolder, olmailitem As Outlook.MailItem, tocontact As Recipient
        Dim conn As Connection
    '***Read command line parameters
        readParameters     'most global variables are set here
    '***Create a new e-mail message
        Set OLF = GetObject("", "outlook.application").GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
        Set olmailitem = OLF.Items.Add
        With olmailitem
    '***    Validate that the email has a recipient
            If mailTo = "" Then
                MsgBox "No hay destinatario para el correo electrónico", vbCritical
            End If
    '***    Set main recipient(s)
            .To = mailTo
    '***    Set secundary recipient(s) if any
            If mailCC <> "" Then .CC = mailCC
    '***    Set subject
            If mailSubject <> "" Then
                .Subject = mailSubject
                .Subject = "Process Confirmation (" & fileName & ")"
            End If
    '***    Set signature
            If mailSignature = "" Then
                mailSignature = "<br><br><br><br><Font face=Mistral size = 5>" _
                & "myName<br><Font face=Arial size = 3>" _
                & "dept and tittle<br>company<br>" _
                & "Phone<br>" _
                & "Fax<br>Email" _
                & "<mailto:myemail>" _
                & "<br><br><br><br><Font face=Arial size = 1>CONFIDENTIALITY NOTICE"
            End If
    '***    If there are result files, create table(s) with results and add to email
            If matchFile <> "" Then
                .HTMLBody = "<Font face=Arial size = 3>" & mailBody & eeResults & mailSignature
                .HTMLBody = "<Font face=Arial size = 3>" & mailBody & mailSignature
            End If
    '***    Add attachment(s)
            If mailAttachment <> "" Then
                .Attachments.Add ""
            End If
    '***    Set date and time at which the item becomes invalid and can be deleted
            .ExpiryTime = Now + 1
    '***    If confirmation is required display email else send without user intervention
            If WaitConfirmation Then
            End If
        End With
    '***Distroy mail objects
        Set tocontact = Nothing
        Set olmailitem = Nothing
        Set OLF = Nothing
    '***Create and open connection to execute sql instruction to indicate process is done
        Set conn = New Connection
        conn.Open connStr
        conn.Execute updateCommand
        Set conn = Nothing
    End Sub
    to err is human ; to really mess things up requires a computer

Posting Permissions

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