How to send cc:Mail from VB or MS Access 
Author Message
 How to send cc:Mail from VB or MS Access

I've been deluged with requests for this code:

Here's code to send cc:mail from Microsoft Access.  "ToAddr" is the
cc:mail address of the
recipient.  "Subject" is the subject.

Dim chan, i
Dim ToAddr As String
Dim Subject As String

' Set ToAddr, Subject field!
On Error Resume Next
' Initiate the conversation
chan = DDEInitiate("wmail", "SendMail")
If Err Then
    MsgBox "cc:Mail isn't running - please start it!"
    Exit Sub
End If
On Error GoTo 0
If IsNull(ToAddr) Then
    MsgBox "Can't send email - address field is blank!"
    Exit Sub
End If
If Len(ToAddr) = 0 Then
    MsgBox "Can't send email - address field is blank!"
    Exit Sub
End If
i = SysCmd(SYSCMD_INITMETER, "Sending email to '" & ToAddr & "'", 100)
DDEExecute chan, "NewMessage"
DDEExecute chan, "TO " & ToAddr
DDEExecute chan, "Subject Re: " & Left$(Subject, 70)
DDEExecute chan, "Receipt 0"
' The text of the message starts here:
DDEExecute chan, "Text This is your email text here." + Chr$(10)
' Here's how to send a blank line...
DDEExecute chan, "Text " + Chr$(10)
DDEExecute chan, "Send"
DDETerminate chan

Here's how to do the same thing in Visual Basic.  To use it, just "Call
SendMail(user, subject,
message)".  Don't forget to put a non-visible Text1 textbox on the form

Sub DDEExecute (chan, cmd)
Text1.LinkExecute cmd
End Sub

Function DDEInitiate (app, topic)
Const MANUAL = 2
Const NONE = 0

Text1.LinkMode = NONE
Text1.LinkTopic = app + "|" + topic
Text1.LinkItem = "Text1"
Text1.LinkMode = MANUAL
DDEInitiate = ""
End Function

Sub DDETerminate (chan)
Const NONE = 0

Text1.LinkMode = NONE
End Sub

Sub SendMail (user As String, subj As String, msg As String)
Dim chan

On Error Resume Next
chan = DDEInitiate("wmail", "SendMail")
If Err <> 0 Then
    On Error GoTo 0
    chan = Shell("s:\mail\ccmail\wmail.exe", 2)
    chan = DDEInitiate("wmail", "SendMail")
    While Err <> 0
        chan = DDEInitiate("wmail", "SendMail")
End If
Call DDEExecute(chan, "NewMessage")
Call DDEExecute(chan, "Subject " & subj)
Call DDEExecute(chan, "Receipt 0")
Call DDEExecute(chan, "Priority Urgent")
Call DDEExecute(chan, "Text " + msg + Chr$(10))
Call DDEExecute(chan, "Text " + Chr$(10))
Call DDEExecute(chan, "TO " & user)
Call DDEExecute(chan, "Send")
Call DDETerminate(chan)
End Sub

Sat, 29 Aug 1998 03:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. How to send cc:Mail from VB or MS Access

2. sending a cc:mail msg from VB

3. sending cc:mail through VB app.

4. need help on formatting a message sent to cc: mail from VB

5. **** Send a mailing using MS ACCESS 95 with or without MS EXCHANGE SERVER *****

6. sending Crystal reports via cc:Mail

7. MAPI - Not able to send mails thru CC and BCC

8. !!! Help Sending mail via MS Access Event Help !!!!

9. sending mail with attachments from ms-access

10. Send mail to MS Mail instead of Outlook

11. Sending mail without using MS Outlook or other mail client

12. Access 8 - CC-Mail 8


Powered by phpBB® Forum Software