Hello,
I use a macro to send emails with an attached picture via Lotus Notes.
The macro is working well but I need to change it so the mail appears to have been sent from a different address than mine.
In a different macro I was able to achieve that by adding the following lines.
They persuade Notes to send/display alternate address
MailDoc.From = "Projet"
MailDoc.SendFrom = "Projet"
MailDoc.DisplayFrom = "Projet"
MailDoc.Principal = "Projet"
I tried to copy those lines after changing "MailDoc" to "UIDoc" but it does't work.
What should I do to update my code to make it work?
Ideally, I would like to be able to send pictures and attach files using the same code.
But the most important is definitively to display a different address.
THANK YOU FOR YOUR HELP.
Here is the code that needs to be modified:
Sub Mail_recap()
Dim MyPic1 As Object
Range("A65000").End(xlUp).Select
Range(Selection, "L1").Select
Set MyPic1 = Selection.SpecialCells(xlCellTypeVisible)
Dim Notes As Object, db As Object, WorkSpace As Object
Dim UIdoc As Object, UserName As String, MailDbName As String
Dim document As Object
Set Notes = CreateObject("Notes.NotesSession")
UserName = Notes.UserName
MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
'Set db = Notes.GetDataBase(vbNullString, MailDbName)
Set db = Notes.GETDATABASE("", "f45.nsf")
Set WorkSpace = CreateObject("Notes.NotesUIWorkspace")
Call WorkSpace.ComposeDocument(, , "Memo")
Set UIdoc = WorkSpace.currentdocument
'Call UIdoc.FieldSetText("SendTo", "elb@test.ch") 'Recipient
Call UIdoc.FieldSetText("EnterSendTo", "elb@test.ch") 'Recipient
Call UIdoc.FieldSetText("Subject", "Recap")
Call UIdoc.GOTOFIELD("Body")
Call UIdoc.INSERTTEXT(WorksheetFunction.Substitute("Hello,@@@", "@", vbCrLf))
MyPic1.Copy: Call UIdoc.Paste
Call UIdoc.INSERTTEXT(String(2, vbCrLf))
Call UIdoc.INSERTTEXT(Application.Substitute("@@@Regards.", "@", vbCrLf))
Application.CutCopyMode = False
'Set document = Maildb.CREATEDOCUMENT
Call UIdoc.Save(True, True)
Call UIdoc.Send(False)
Set docc = UIdoc.document
With docc
.SaveOptions = "0"
End With
Call UIdoc.Close(True)
Set UIdoc = Nothing
Set WorkSpace = Nothing
Set db = Nothing
Set Notes = Nothing
End Sub
I use a macro to send emails with an attached picture via Lotus Notes.
The macro is working well but I need to change it so the mail appears to have been sent from a different address than mine.
In a different macro I was able to achieve that by adding the following lines.
They persuade Notes to send/display alternate address
MailDoc.From = "Projet"
MailDoc.SendFrom = "Projet"
MailDoc.DisplayFrom = "Projet"
MailDoc.Principal = "Projet"
I tried to copy those lines after changing "MailDoc" to "UIDoc" but it does't work.
What should I do to update my code to make it work?
Ideally, I would like to be able to send pictures and attach files using the same code.
But the most important is definitively to display a different address.
THANK YOU FOR YOUR HELP.
Here is the code that needs to be modified:
Sub Mail_recap()
Dim MyPic1 As Object
Range("A65000").End(xlUp).Select
Range(Selection, "L1").Select
Set MyPic1 = Selection.SpecialCells(xlCellTypeVisible)
Dim Notes As Object, db As Object, WorkSpace As Object
Dim UIdoc As Object, UserName As String, MailDbName As String
Dim document As Object
Set Notes = CreateObject("Notes.NotesSession")
UserName = Notes.UserName
MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
'Set db = Notes.GetDataBase(vbNullString, MailDbName)
Set db = Notes.GETDATABASE("", "f45.nsf")
Set WorkSpace = CreateObject("Notes.NotesUIWorkspace")
Call WorkSpace.ComposeDocument(, , "Memo")
Set UIdoc = WorkSpace.currentdocument
'Call UIdoc.FieldSetText("SendTo", "elb@test.ch") 'Recipient
Call UIdoc.FieldSetText("EnterSendTo", "elb@test.ch") 'Recipient
Call UIdoc.FieldSetText("Subject", "Recap")
Call UIdoc.GOTOFIELD("Body")
Call UIdoc.INSERTTEXT(WorksheetFunction.Substitute("Hello,@@@", "@", vbCrLf))
MyPic1.Copy: Call UIdoc.Paste
Call UIdoc.INSERTTEXT(String(2, vbCrLf))
Call UIdoc.INSERTTEXT(Application.Substitute("@@@Regards.", "@", vbCrLf))
Application.CutCopyMode = False
'Set document = Maildb.CREATEDOCUMENT
Call UIdoc.Save(True, True)
Call UIdoc.Send(False)
Set docc = UIdoc.document
With docc
.SaveOptions = "0"
End With
Call UIdoc.Close(True)
Set UIdoc = Nothing
Set WorkSpace = Nothing
Set db = Nothing
Set Notes = Nothing
End Sub