send a mail in VBA with an other account than the default one
send a mail in VBA with an other account than the default one
send a mail in VBA with an other account than the default one
send a mail in VBA with an other account than the default one
send a mail in VBA with an other account than the default one
send a mail in VBA with an other account than the default one send a mail in VBA with an other account than the default one send a mail in VBA with an other account than the default one send a mail in VBA with an other account than the default one send a mail in VBA with an other account than the default one send a mail in VBA with an other account than the default one send a mail in VBA with an other account than the default one send a mail in VBA with an other account than the default one
send a mail in VBA with an other account than the default one send a mail in VBA with an other account than the default one
send a mail in VBA with an other account than the default one
Go Back  Xtreme Visual Basic Talk > > > send a mail in VBA with an other account than the default one


Reply
 
Thread Tools Display Modes
  #1  
Old 06-17-2003, 04:17 AM
Belgarion2 Belgarion2 is offline
Newcomer
 
Join Date: Jun 2003
Posts: 1
Default send a mail in VBA with an other account than the default one


sorry for my english level but i m french

i have made a program in VBA to send multiple fax. the number are in an Access 2000 base and i use outlook 2000 and delrina fax starter edition to send the fax (it work like a standard mail send with a special mail account).

the problem I have is that I need to have delrina data fax starter in default mail account for it work and it's a big probleme for me.

So my question is how to do :

- does it exist a propertie like Mailitem.SendWithAccount xxxx so the mail i create will be automaticly send with the account symantec

- Or can i change the default email account in outlook with VBA

- Or someone have an other solution

Thanks for all help you can give to me
Reply With Quote
  #2  
Old 07-23-2009, 08:22 AM
parthipbn parthipbn is offline
Newcomer
 
Join Date: Jul 2009
Posts: 1
Default

Quote:
Originally Posted by wmt7
I am trying to send email from MS Access through Outllook using VB.

I have multiple accounts set up in Outlook and would like to change the "Reply-to" and "Sent from" to an account other than the default.

Is there a way to do this programatcally using VB.
I have tried .sendername = "Other than deafult" to no avail.

Any insight would be great.

PS. I think this can be done using CDONTS - but I would prefer not to use that route.

Thanks>
Hi, i had the same question to myself and i found redemption to be the only solution for this.

I feel the following function may be useful to you.

'Sends mail through intended account
'Recipients should be seperated by semicolon(;)
Function SendMail(ByVal sAccountName As String, _
ByVal sTo As String, _
ByVal sSubject As String, _
ByVal sBody As String, _
Optional ByVal sCC As String = "", _
Optional ByVal sBCC As String = "", _
Optional ByVal bHTML As Boolean = False) As Boolean

On Error GoTo Errhdlr

Dim oNS As Outlook.Namespace
Dim oSession As Redemption.RDOSession
Dim oMail As Outlook.mailItem
Dim oRDOMail As RDOMail
Dim oOLApp As Outlook.Application
Dim iCtr As Integer
Dim asIDs() As String
Dim oRecipient As recipient


'Doing preliminary checks

If sAccountName = "" Then
GoTo Endpoint
End If

If sTo = "" Then
GoTo Endpoint
End If

Set oOLApp = Outlook.Application
Set oNS = oOLApp.GetNamespace("MAPI")
oNS.Logon

Set oSession = New Redemption.RDOSession
oSession.MAPIOBJECT = oNS.MAPIOBJECT

If (oSession.LoggedOn) Then
Set oMail = oOLApp.CreateItem(olMailItem)

With oMail

'Adding recepient(s)
If InStr(sTo, ";") > 0 Then

asIDs = Split(sTo, ";")
For iCtr = 0 To UBound(asIDs)
Set oRecipient = .Recipients.Add(asIDs(iCtr))
oRecipient.Type = olTo
Next iCtr

If Not .Recipients.ResolveAll Then
GoTo Endpoint
End If

Else
.To = sTo
End If

'Adding subject
.Subject = sSubject

'Adding message body
If bHTML Then
.HTMLBody = sBody
Else
.Body = sBody
End If

'Adding CC
If InStr(sCC, ";") > 0 Then

asIDs = Split(sCC, ";")
For iCtr = 0 To UBound(asIDs)
Set oRecipient = .Recipients.Add(asIDs(iCtr))
oRecipient.Type = olCC
Next iCtr

If Not .Recipients.ResolveAll Then
GoTo Endpoint
End If

Else
.CC = sCC
End If

'Adding BCC
If InStr(sBCC, ";") > 0 Then

asIDs = Split(sBCC, ";")

For iCtr = 0 To UBound(asIDs)
Set oRecipient = .Recipients.Add(asIDs(iCtr))
oRecipient.Type = olBCC
Next iCtr

If Not .Recipients.ResolveAll Then
GoTo Endpoint
End If

Else
.BCC = sBCC
End If

oMail.Save

'Sleep (1000)

'Setting up the account
Set oRDOMail = oSession.GetMessageFromID(oMail.EntryID)
oRDOMail.Account = oSession.Accounts(sAccountName)

oRDOMail.Send
SendMail = True
End With
Else
SendMail = False
End If

GoTo Endpoint

Errhdlr:
MsgBox Err.Description
Endpoint:
End Function


Note: you need Redemption.dll to get it to work. Don't forget to add reference to 'Redemption Outlook and COM library'.

(I know that this reply is too late but, it believe that it will be helpful for many)

Happy Coding ;)
-parthi
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change default email account from VB in Outlook alex3d Communications 5 04-08-2003 04:58 AM
Rows that exceed the maximum number of bytes will not be added jollyguy4all Database and Reporting 4 03-27-2003 10:43 AM
Default Mail Account hard to set Braganca Communications 4 02-19-2003 03:59 AM
MAPI send mail troubles.... grimes Communications 0 02-15-2002 08:18 AM
Opening default mail program Neptune General 2 02-16-2001 09:09 AM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
send a mail in VBA with an other account than the default one
send a mail in VBA with an other account than the default one
send a mail in VBA with an other account than the default one send a mail in VBA with an other account than the default one
send a mail in VBA with an other account than the default one
send a mail in VBA with an other account than the default one
send a mail in VBA with an other account than the default one send a mail in VBA with an other account than the default one send a mail in VBA with an other account than the default one send a mail in VBA with an other account than the default one send a mail in VBA with an other account than the default one send a mail in VBA with an other account than the default one send a mail in VBA with an other account than the default one
send a mail in VBA with an other account than the default one
send a mail in VBA with an other account than the default one
 
send a mail in VBA with an other account than the default one
send a mail in VBA with an other account than the default one
 
-->